Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2785844pxj; Mon, 10 May 2021 10:40:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlJ2ueXygGiVqH3KlJFP6sdWH0peC89GwoHlecw8q/Y8MnIUVNlwmA8PeIBmkiYUEb2TVo X-Received: by 2002:a05:6638:a2c:: with SMTP id 12mr22442275jao.99.1620668403020; Mon, 10 May 2021 10:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620668403; cv=none; d=google.com; s=arc-20160816; b=Ya9wVjMs0MqYmSvv7JfjtvTFJbt1oiShyl3Wj+UQPmzYc3AhPrAByk5/sEqZGfPuTI qKVC5Sw8dscycIPU31I1+h/zSnOq1+S/38j5qaNPhbDbtolgN4VHsMyFU8mcAvoko8/J 4a8NrGisGCL2lL9F/ihP5ljh6zbh7ttPAUnMkSEK6XXSOqRIlyKr7n4d0WOQe96jCRbu cMaqoOOW6CAx2cqbxZ3jSXkfKfXcDfvUQDGrVvEbdO3ZPJX2lOjqv9eynFzQ0Chz/L/I W5xlUhXg2S1DVXK8OqH4xa65GcNfA32qr3F9Jrh3SP33e2cY3OIW9vmXn7Ts4qyxrhBm jteA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=5pOLb5EfE9pWSi+83ZspnvhOzLwEscESl5Af4/6ZijU=; b=SSYGF8c4OSqJkoyFLM7tTnhrY0rE907ZWyOwzFwUliWK47suCH8VFT3/2W/F+saEFV vARX/ac8GpCqTRoNch6MCvB6qfBKDkRPSIB0CuZ5TV+Zoh4Jyzdm6//wDN/1ffMkTDXO u7B05Qa4Q7qyh83JSRCbImPR7DhykRG7+sJfj6oy/ekImixLZxEoYydcF8iAL8sV8WvV NG/HVo15RdtgsQD/2CYDreZ1Xtx8qEHrf0gURU34bkJcMZuvOKi0SlXAEeD3b2ybFXaG jJt3o2dDniCtnx33SbWgGMjYjSUQkCqg6hgngMxCsfihbeRi6ZyHGmmc7n/dzW6Mxfg4 qGvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si16743565iln.13.2021.05.10.10.39.49; Mon, 10 May 2021 10:40:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231707AbhEJRkO (ORCPT + 99 others); Mon, 10 May 2021 13:40:14 -0400 Received: from smtprelay0124.hostedemail.com ([216.40.44.124]:37000 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230507AbhEJRkN (ORCPT ); Mon, 10 May 2021 13:40:13 -0400 Received: from omf07.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 52048837F27B; Mon, 10 May 2021 17:39:07 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf07.hostedemail.com (Postfix) with ESMTPA id 9B5FC315D82; Mon, 10 May 2021 17:39:06 +0000 (UTC) Message-ID: <630fc44bfb88f8d3d542c084c2d9f7c0a6d8aea7.camel@perches.com> Subject: Re: [PATCH] checkpatch: auto detect codespell dictionary path From: Joe Perches To: Dwaipayan Ray Cc: linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com Date: Mon, 10 May 2021 10:39:05 -0700 In-Reply-To: <20210510171127.15056-1-dwaipayanray1@gmail.com> References: <20210510171127.15056-1-dwaipayanray1@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.87 X-Stat-Signature: m7kffn3zzbpqdc8wza5mbk5gy45z836s X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: 9B5FC315D82 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18lb2+7QkLKJXxM0h5ZWEvgHf9j5olsgQw= X-HE-Tag: 1620668346-785097 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-05-10 at 22:41 +0530, Dwaipayan Ray wrote: > The codespell dictionary was moved from > `/usr/share/codespell/dictionary.txt` to data/dictionary.txt > under the codespell_lib installation directory. > > Checkpatch still uses a default absolute path for it which will > no longer work on new codespell installations unless the path > is specified through --codespellfile. > > Detect the codespell dictionary path dynamically during > runtime if the default path or the user provided dictionary > path does not exist. [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -889,6 +889,13 @@ if (open(my $spelling, '<', $spelling_file)) { > ?} > ? > > ?if ($codespell) { > + if (! -e "$codespellfile" && which("python3") ne "") { > + my $output = `python3 -c "import codespell_lib; print(codespell_lib.__file__, end='');" 2>/dev/null`; It doesn't seem to me that using python3 is a great way to invoke python. Maybe test the external command return $? when codespell isn't installed. > + my $dictionary_path = dirname($output) . "/data/dictionary.txt"; Unlikely, but this could still end up with a existing file of /data/dictionary.txt that is not a codespell file. > + if (-e "$dictionary_path") { > + $codespellfile = $dictionary_path; > + } > + } > ? if (open(my $spelling, '<', $codespellfile)) { > ? while (<$spelling>) { > ? my $line = $_;