linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@dabbelt.com>
To: linux-kernel@vger.kernel.org
Cc: apw@canonical.com, joe@perches.com, linux-kernel@vger.kernel.org,
	kernel-team@android.com,
	Palmer Dabbelt <palmerdabbelt@google.com>
Subject: [PATCH] checkpatch: Allow users to specify the python command to use
Date: Tue, 21 Apr 2020 10:36:05 -0700	[thread overview]
Message-ID: <20200421173604.38979-1-palmer@dabbelt.com> (raw)

From: Palmer Dabbelt <palmerdabbelt@google.com>

checkpatch.pl invokes spdxcheck.py using "python".  On my system that's
Python 2, but I only have a git package for Python 3.  This patch adds a
"--python=..." argument to checkpatch.pl that allows users to specify a
command to invoke Python.  I've just given this a little smoke test:
running it without any arguments still works, and running with
--python=python3 finds the git module.

Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>

---
I'd considered reading some sort of environment variable, but searching
for "getenv" in checkpatch.pl didn't reveal any other enviornment
variables so I figured it'd be cleaner to avoid adding one.  I only
invoke checkpatch.pl from wrapper scripts anyway, so it's the same for
me.
---
 scripts/checkpatch.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d64c67b67e3c..05ce52a2aaa9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -65,6 +65,7 @@ my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANC
 # git output parsing needs US English output, so first set backtick child process LANGUAGE
 my $git_command ='export LANGUAGE=en_US.UTF-8; git';
 my $tabsize = 8;
+my $python = "python";
 
 sub help {
 	my ($exitcode) = @_;
@@ -125,6 +126,7 @@ Options:
   --typedefsfile             Read additional types from this file
   --color[=WHEN]             Use colors 'always', 'never', or only when output
                              is a terminal ('auto'). Default is 'auto'.
+  --python=COMMAND           Use the give command to invoke python.
   -h, --help, --version      display this help and exit
 
 When FILE is - read standard input.
@@ -233,6 +235,7 @@ GetOptions(
 	'color=s'	=> \$color,
 	'no-color'	=> \$color,	#keep old behaviors of -nocolor
 	'nocolor'	=> \$color,	#keep old behaviors of -nocolor
+	'python=s'      => \$python,
 	'h|help'	=> \$help,
 	'version'	=> \$help
 ) or help(1);
@@ -897,10 +900,10 @@ sub is_maintained_obsolete {
 sub is_SPDX_License_valid {
 	my ($license) = @_;
 
-	return 1 if (!$tree || which("python") eq "" || !(-e "$root/scripts/spdxcheck.py") || !(-e "$root/.git"));
+	return 1 if (!$tree || which($python) eq "" || !(-e "$root/scripts/spdxcheck.py") || !(-e "$root/.git"));
 
 	my $root_path = abs_path($root);
-	my $status = `cd "$root_path"; echo "$license" | python scripts/spdxcheck.py -`;
+	my $status = `cd "$root_path"; echo "$license" | $python scripts/spdxcheck.py -`;
 	return 0 if ($status ne "");
 	return 1;
 }
-- 
2.26.1.301.g55bc3eb7cb9-goog


                 reply	other threads:[~2020-04-21 17:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200421173604.38979-1-palmer@dabbelt.com \
    --to=palmer@dabbelt.com \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=palmerdabbelt@google.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;
as well as URLs for NNTP newsgroup(s).