Subject: [PATCH] py-compile: Allow user to disable python

From: Frédéric Bérat <[email-masked]>
Date: Tue, 19 Nov 2024 10:52:02 +0100

Hello,

While integrating automake 1.17, I found that otf2 package build fails.
The failure is due to:
	py-compile: could not determine : major version

This is a side-effect of a rework of the py-compile script, which
formerly defaulted to python3 if there was an error while getting the
python version.

The new code doesn't have this fallback, and if users want to disable
python support by setting `PYTHON=:` as environment variable, the script
bails out.

I believe this is a common practice and that py-compile needs a fix. I
therefore propose the one below.

Feel free to tell me otherwise.

Fred.

-- 8< --
Subject: [PATCH] py-compile: Allow user to disable python

Common practice is to set PYTHON=: to disable python support, which
breaks the current version of this script.

Check that the PYTHON variable contains `python`, early exit otherwise.
---
 lib/py-compile | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/py-compile b/lib/py-compile
index c9d4fde94..0238bab2c 100755
--- a/lib/py-compile
+++ b/lib/py-compile
@@ -33,6 +33,13 @@ fi
 
 me=py-compile
 
+case "$PYTHON" in
+  *python*) ;;
+  *)
+  echo "$me: Python support disabled";
+  exit 0;;
+esac
+
 usage_error ()
 {
   echo "$me: $*" >&2
-- 
2.47.0