From: Sagar Patel <sagarmp@cs.unc.edu>
To: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
linux-kernel@vger.kernel.org, Sagar Patel <sagarmp@cs.unc.edu>
Subject: [PATCH] checkpatch: use python3 to find codespell dictionary
Date: Mon, 7 Mar 2022 21:55:48 -0500 [thread overview]
Message-ID: <20220308025547.20412-1-sagarmp@cs.unc.edu> (raw)
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
binary 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 the dictionary, do not check if the
codespell binary exists since codespell can be installed via a Python
package manager. In this case, a codespell binary is not exported in
$PATH, but a dictionary does exist.
Signed-off-by: Sagar Patel <sagarmp@cs.unc.edu>
---
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b01c36a15d9d..46302e074b18 100755
--- a/scripts/checkpatch.pl
+++ b/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: <codespell_root>/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, 'data', 'dictionary.txt')
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);
}
}
--
2.25.1
next reply other threads:[~2022-03-08 2:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 2:55 Sagar Patel [this message]
2022-03-08 7:58 ` Péter Ujfalusi
2022-03-09 18:01 ` Sagar Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220308025547.20412-1-sagarmp@cs.unc.edu \
--to=sagarmp@cs.unc.edu \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.ujfalusi@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®