[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[automake-commit] branch master updated: python: restore more compatible
From: |
Karl Berry |
Subject: |
[automake-commit] branch master updated: python: restore more compatible behavior for $PYTHON. |
Date: |
Sun, 09 Feb 2025 12:36:46 -0500 |
This is an automated email from the git hooks/post-receive script.
karl pushed a commit to branch master
in repository automake.
View the commit online:
https://git.savannah.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=0ea7ef97493cd88da915d1936e04a6ace5c754d8
The following commit(s) were added to refs/heads/master by this push:
new 0ea7ef974 python: restore more compatible behavior for $PYTHON.
0ea7ef974 is described below
commit 0ea7ef97493cd88da915d1936e04a6ace5c754d8
Author: Karl Berry <karl@freefriends.org>
AuthorDate: Sun Feb 9 09:36:24 2025 -0800
python: restore more compatible behavior for $PYTHON.
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 | 15 +++++++++++----
lib/py-compile | 27 ++++++++++++++++++++++++++-
t/py-compile-env.sh | 6 ++++++
3 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index f667c8727..22bd6a585 100644
--- 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
diff --git a/lib/py-compile b/lib/py-compile
index 9659beca6..0cfddedb6 100755
--- a/lib/py-compile
+++ b/lib/py-compile
@@ -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/>.
diff --git a/t/py-compile-env.sh b/t/py-compile-env.sh
index 564fb98c6..3411ddd5d 100644
--- a/t/py-compile-env.sh
+++ b/t/py-compile-env.sh
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [automake-commit] branch master updated: python: restore more compatible behavior for $PYTHON.,
Karl Berry <=