From patchwork Wed Mar 23 23:06:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12790216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B228C433EF for ; Wed, 23 Mar 2022 23:06:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E65636B0080; Wed, 23 Mar 2022 19:06:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E15A96B0081; Wed, 23 Mar 2022 19:06:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDDBE8D0003; Wed, 23 Mar 2022 19:06:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0153.hostedemail.com [216.40.44.153]) by kanga.kvack.org (Postfix) with ESMTP id BF46F6B0080 for ; Wed, 23 Mar 2022 19:06:09 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 84D5C182592E1 for ; Wed, 23 Mar 2022 23:06:09 +0000 (UTC) X-FDA: 79277186058.30.94DA1F8 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf09.hostedemail.com (Postfix) with ESMTP id 0E468140027 for ; Wed, 23 Mar 2022 23:06:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AA6F8B8214D; Wed, 23 Mar 2022 23:06:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E217C340E8; Wed, 23 Mar 2022 23:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648076766; bh=PORcXoKh9ikcpSwJrXxJv1CqfS82VJJi9nCh7sf/4tM=; h=Date:To:From:In-Reply-To:Subject:From; b=AxEFl7W3eM61RYA84zTdLPfuAulmrhhfXAVxIm6V0HFdHHandFT+EOGbdYDMtDnGs /J//oybSi26vvwiQBZjvnDqK1Vrs210Q3Nxh5kEc68eyeR/wEOerbzAB0eK/HlNfHL SF1xc4xBFeM9RX85RXDUgdFtCJgKo3tOCdWLS1LE= Date: Wed, 23 Mar 2022 16:06:05 -0700 To: peter.ujfalusi@linux.intel.com,joe@perches.com,sagarmp@cs.unc.edu,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220323160453.65922ced539cbf445b191555@linux-foundation.org> Subject: [patch 16/41] checkpatch: use python3 to find codespell dictionary Message-Id: <20220323230606.4E217C340E8@smtp.kernel.org> Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=AxEFl7W3; spf=pass (imf09.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: gifm1is6wxhhw5y99jbhmmsb1g53a79g X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0E468140027 X-HE-Tag: 1648076768-997019 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Sagar Patel Subject: checkpatch: use python3 to find codespell dictionary Commit 0ee3e7b8893e ("checkpatch: get default codespell dictionary path from package location") introduced the ability to search for the codespell dictionary rather than hardcoding its path. codespell requires Python 3.6 or above, but on some systems, the python executable is a Python 2.7 interpreter. In this case, searching for the dictionary fails, subsequently making codespell fail: No codespell typos will be found - file '/usr/share/codespell/dictionary.txt': No such file or directory So, use python3 to remove ambiguity. In addition, when searching for dictionary.txt, do not check if the codespell executable exists since, - checkpatch.pl only uses dictionary.txt, not the codespell executable. - codespell can be installed via a Python package manager, in which case the codespell executable may not be present in a typical $PATH, but a dictionary does exist. Link: https://lkml.kernel.org/r/20220309180048.147672-1-sagarmp@cs.unc.edu Signed-off-by: Sagar Patel Reviewed-by: Peter Ujfalusi Cc: Joe Perches Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/scripts/checkpatch.pl~checkpatch-use-python3-to-find-codespell-dictionary +++ a/scripts/checkpatch.pl @@ -334,7 +334,7 @@ if ($user_codespellfile) { } elsif (!(-f $codespellfile)) { # If /usr/share/codespell/dictionary.txt is not present, try to find it # under codespell's install directory: /data/dictionary.txt - if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") { + if (($codespell || $help) && which("python3") ne "") { my $python_codespell_dict = << "EOF"; import os.path as op @@ -344,7 +344,7 @@ codespell_file = op.join(codespell_dir, print(codespell_file, end='') EOF - my $codespell_dict = `python -c "$python_codespell_dict" 2> /dev/null`; + my $codespell_dict = `python3 -c "$python_codespell_dict" 2> /dev/null`; $codespellfile = $codespell_dict if (-f $codespell_dict); } }