[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[automake-commit] branch master updated: py-compile: drop support for Py
From: |
Mike Frysinger |
Subject: |
[automake-commit] branch master updated: py-compile: drop support for Python 0.x & 1.x |
Date: |
Mon, 07 Feb 2022 21:55:51 -0500 |
This is an automated email from the git hooks/post-receive script.
vapier 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=8b2d281d54afcc1e8b7e9a92751b5bbc7619ff5a
The following commit(s) were added to refs/heads/master by this push:
new 8b2d281d5 py-compile: drop support for Python 0.x & 1.x
8b2d281d5 is described below
commit 8b2d281d54afcc1e8b7e9a92751b5bbc7619ff5a
Author: Mike Frysinger <vapier@gentoo.org>
AuthorDate: Sun Feb 6 00:22:50 2022 -0500
py-compile: drop support for Python 0.x & 1.x
Python 2.0 was released in 2000. There's really no way for us to check
those old versions, so let's just drop them. No one will miss them.
* NEWS: Note Python version support removal.
* lib/py-compile: Abort if major version 0 or 1 is found.
* t/py-compile-env.sh: Rework slightly to handle new version probing.
---
NEWS | 5 +++++
lib/py-compile | 37 ++++++++++++++-----------------------
t/py-compile-env.sh | 4 +---
3 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/NEWS b/NEWS
index f40860507..29c4d8a96 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,11 @@ New in 1.17:
- AM_TEXI2FLAGS may be defined to pass extra flags to TEXI2DVI & TEXI2PDF.
+* Obsolescent features:
+
+ - py-compile no longer supports Python 0.x or 1.x versions. Python 2.0,
+ released in 2000, is currently the minimum required version.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
New in 1.16.5:
diff --git a/lib/py-compile b/lib/py-compile
index ccf406235..734bd6a3c 100755
--- a/lib/py-compile
+++ b/lib/py-compile
@@ -1,7 +1,7 @@
#!/bin/sh
# py-compile - Compile a Python program
-scriptversion=2022-02-06.05; # UTC
+scriptversion=2022-02-06.06; # UTC
# Copyright (C) 2000-2022 Free Software Foundation, Inc.
@@ -120,27 +120,19 @@ else
filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
fi
-python_major=`$PYTHON -V 2>&1 | sed -e 's/.* //;s/\..*$//;1q'`
+python_major=`$PYTHON -c 'import sys; print(sys.version_info[0])'`
if test -z "$python_major"; then
- echo "$me: could not determine $PYTHON major version, guessing 3" >&2
- python_major=3
+ usage_error "could not determine $PYTHON major version"
fi
-# The old way to import libraries was deprecated.
-if test "$python_major" -le 2; then
- import_lib=imp
- import_test="hasattr(imp, 'get_tag')"
- import_call=imp.cache_from_source
- import_arg2=', False' # needed in one call and not the other
-else
- import_lib=importlib
- import_test="hasattr(sys.implementation, 'cache_tag')"
- import_call=importlib.util.cache_from_source
- import_arg2=
-fi
+case $python_major in
+[01])
+ usage_error "python version 0.x and 1.x not supported"
+ ;;
+esac
$PYTHON -c "
-import sys, os, py_compile, $import_lib
+import sys, os, py_compile, importlib
sys.stdout.write('Byte-compiling python modules...\n')
for file in sys.argv[1:]:
@@ -151,15 +143,14 @@ for file in sys.argv[1:]:
continue
sys.stdout.write(file)
sys.stdout.flush()
- if $import_test:
- py_compile.compile(filepath, $import_call(filepath), path)
+ if hasattr(sys.implementation, 'cache_tag'):
+ py_compile.compile(filepath,
importlib.util.cache_from_source(filepath), path)
else:
py_compile.compile(filepath, filepath + 'c', path)
sys.stdout.write('\n')" "$@" || exit $?
-# this will fail for python < 1.5, but that doesn't matter ...
$PYTHON -O -c "
-import sys, os, py_compile, $import_lib
+import sys, os, py_compile, importlib
# pypy does not use .pyo optimization
if hasattr(sys, 'pypy_translation_info'):
@@ -174,8 +165,8 @@ for file in sys.argv[1:]:
continue
sys.stdout.write(file)
sys.stdout.flush()
- if $import_test:
- py_compile.compile(filepath, $import_call(filepath$import_arg2), path)
+ if hasattr(sys.implementation, 'cache_tag'):
+ py_compile.compile(filepath,
importlib.util.cache_from_source(filepath), path)
else:
py_compile.compile(filepath, filepath + 'o', path)
sys.stdout.write('\n')" "$@" 2>/dev/null || exit $?
diff --git a/t/py-compile-env.sh b/t/py-compile-env.sh
index 2c7fe5084..e79985892 100644
--- a/t/py-compile-env.sh
+++ b/t/py-compile-env.sh
@@ -23,6 +23,7 @@ cp "$am_scriptdir/py-compile" . \
cat > my-py <<'END'
#!/bin/sh
+echo 2
: > my-py.run
END
chmod a+x my-py
@@ -30,9 +31,6 @@ chmod a+x my-py
mkdir sub1
cd sub1
-PYTHON=: ../py-compile foo.py
-ls | grep . && exit 1
-
PYTHON=false ../py-compile foo.py && exit 1
ls | grep . && exit 1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [automake-commit] branch master updated: py-compile: drop support for Python 0.x & 1.x,
Mike Frysinger <=