]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
python: restore more compatible behavior for $PYTHON.
authorKarl Berry <karl@freefriends.org>
Sun, 9 Feb 2025 17:36:24 +0000 (09:36 -0800)
committerKarl Berry <karl@freefriends.org>
Sun, 9 Feb 2025 17:36:24 +0000 (09:36 -0800)
For https://bugs.gnu.org/74434.

* lib/py-compile: if $PYTHON -V does not include the
string "python" (case-insensitive), consider the support
intentionally disabled and exit successfully, unless PYTHON is set
to false, in which case exit unsuccessfully. This is closer to
the old behavior. Mention this in the help message.
* t/py-compile-env.sh: add test for PYTHON=:.
* NEWS: mention this. (And, en passant, add some past bug#s and
clarify that only RCS/SCCS pattern rules were disabled, not all.)

NEWS
lib/py-compile
t/py-compile-env.sh

diff --git a/NEWS b/NEWS
index f667c8727e15f149dbf7fef543fd3cda83709479..22bd6a5853ae0c576b14853e6d1c9c488eb98585 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,7 @@ New in 1.x:
 
 * New supported languages
 
-  - Support for Algol 68 added, based on the GNU Algol 68 compiler.
+  - Support for Algol 68 added, based on the GNU Algol 68 compiler. (bug#75807)
 
 * Miscellaneous changes
 
@@ -19,7 +19,14 @@ New in 1.x:
 
   - Avoid Perl 5.41.8+ precedence warning for use of !!.
 
-  - The compile script is more robust to various Windows configurations.
+  - The py-compile script once again does nothing (successfully) if the
+    PYTHON environment variable is set to ":", or anything that isn't a
+    Python interpreter (according to $PYTHON -V). Exception: if PYTHON
+    is set to "false", do nothing but exit unsuccessfully, also to match
+    previous behavior. (bug#74434)
+
+  - The compile script is more robust to Windows configurations;
+    specifically, avoiding double-path translation on MSYS. (bug#75939)
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -51,8 +58,8 @@ New in 1.17:
     retained when appended.  GNU Make & BSD Makes are known to support it.
     (bug#7610)
 
-  - GNU Make's default pattern rules are disabled, for speed and debugging.
-    (.SUFFIXES was already cleared.) (bug#64743)
+  - GNU Make's default pattern rules for RCS and SCCS are disabled, for
+    speed and debugging. (.SUFFIXES was already cleared.) (bug#64743)
 
   - For Texinfo documents, if a .texi.in file exists, but no .texi, the
     .texi.in will be read. Texinfo source files need not be present at
index 9659beca639bf5890512b907103eaaff7e009b11..0cfddedb60bc54cab7e212d47e0ab86645253697 100755 (executable)
@@ -33,6 +33,23 @@ fi
 
 me=py-compile
 
+# People apparently set PYTHON=: and expect the result to be true.
+# For the same reason, we output to stdout instead of stderr. Bizarre.
+if $PYTHON -V 2>/dev/null | grep -i python >/dev/null; then :; else
+  echo "$me: Invalid python executable (according to -V): $PYTHON"
+  echo "$me: Python support disabled"
+  if test x"$PYTHON" = xfalse; then
+    # But, as a special case, make PYTHON=false exit unsuccessfully,
+    # since that was the traditional behavior.
+    exit 1
+    # In the past, setting PYTHON to any command that exited unsuccessfully
+    # caused py-compile to exit unsuccessfully. Let's not try to
+    # replicate that unless and until needed.
+  else
+   exit 0
+  fi
+fi
+  
 usage_error ()
 {
   echo "$me: $*" >&2
@@ -64,7 +81,7 @@ while test $# -ne 0; do
       cat <<\EOF
 Usage: py-compile [options] FILES...
 
-Byte compile some python scripts FILES.  Use --destdir to specify any
+Byte compile FILES as Python scripts.  Use --destdir to specify a
 leading directory path to the FILES that you don't want to include in the
 byte compiled file.  Specify --basedir for any additional path information you
 do want to be shown in the byte compiled file.
@@ -78,6 +95,14 @@ Options:
 Example:
   py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py
 
+The Python interpreter to use is taken from the environment variable
+PYTHON, or "python" by default.
+
+For compatibility: as a special case, if PYTHON=false (that is, the
+command named "false"), this script will exit unsuccessfully. Otherwise,
+if $PYTHON -V does not include the string "Python", this script will
+emit a message to standard output and exit successfully.
+
 Report bugs to <bug-automake@gnu.org>.
 GNU Automake home page: <https://www.gnu.org/software/automake/>.
 General help using GNU software: <https://www.gnu.org/gethelp/>.
index 564fb98c6d803ae8af484386cc6b70ad78c44cff..3411ddd5d832ada0955d886ef3b0ad5a459bc31b 100644 (file)
@@ -31,9 +31,15 @@ chmod a+x my-py
 mkdir sub1
 cd sub1
 
+# This py-compile invocation should succeed and do nothing.
+PYTHON=: ../py-compile foo.py
+ls | grep . && exit 1
+
+# This py-compile invocation should fail and do nothing.
 PYTHON=false ../py-compile foo.py && exit 1
 ls | grep . && exit 1
 
+# These should also do nothing, and succeed.
 PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py
 PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py | grep 'GrEpMe AndMeToo'
 ls | grep . && exit 1