|
|
2ea2ea |
From e21d46fddd0753e66a4acda88317670fee07f3e6 Mon Sep 17 00:00:00 2001
|
|
|
2ea2ea |
From: "Miro Hron\\v{c}ok" <miro@hroncok.cz>
|
|
|
2ea2ea |
Date: Tue, 27 Oct 2020 14:33:46 -0700
|
|
|
2ea2ea |
Subject: [PATCH] python: determine Python (3.10) version number correctly.
|
|
|
2ea2ea |
|
|
|
2ea2ea |
This change fixes https://bugs.gnu.org/44239
|
|
|
2ea2ea |
(and https://bugzilla.redhat.com/show_bug.cgi?id=1889732).
|
|
|
2ea2ea |
|
|
|
2ea2ea |
* m4/python.m4: use print('%u.%u' % sys.version_info[:2]) for
|
|
|
2ea2ea |
the version number instead of merely sys.version[:3], so the
|
|
|
2ea2ea |
numbers are treated as numbers.
|
|
|
2ea2ea |
* t/python-vars.sh (PYTHON_VERSION): Likewise.
|
|
|
2ea2ea |
* doc/automake.texi: Document it.
|
|
|
2ea2ea |
* NEWS: mention it. (Minor tweaks from Karl Berry.)
|
|
|
2ea2ea |
---
|
|
|
2ea2ea |
NEWS | 2 ++
|
|
|
2ea2ea |
doc/automake.texi | 2 +-
|
|
|
2ea2ea |
m4/python.m4 | 12 +++++++-----
|
|
|
2ea2ea |
t/python-vars.sh | 4 +++-
|
|
|
2ea2ea |
4 files changed, 13 insertions(+), 7 deletions(-)
|
|
|
2ea2ea |
|
|
|
2ea2ea |
diff --git a/doc/automake.texi b/doc/automake.texi
|
|
|
2ea2ea |
index ed7e2e242..17bc2dae6 100644
|
|
|
2ea2ea |
--- a/doc/automake.texi
|
|
|
2ea2ea |
+++ b/doc/automake.texi
|
|
|
2ea2ea |
@@ -7861,7 +7861,7 @@ AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
|
|
|
2ea2ea |
@item PYTHON_VERSION
|
|
|
2ea2ea |
The Python version number, in the form @var{major}.@var{minor}
|
|
|
2ea2ea |
(e.g., @samp{2.5}). This is currently the value of
|
|
|
2ea2ea |
-@samp{sys.version[:3]}.
|
|
|
2ea2ea |
+@samp{'%u.%u' % sys.version_info[:2]}.
|
|
|
2ea2ea |
|
|
|
2ea2ea |
@item PYTHON_PREFIX
|
|
|
2ea2ea |
The string @samp{$@{prefix@}}. This term may be used in future work
|
|
|
2ea2ea |
diff --git a/m4/python.m4 b/m4/python.m4
|
|
|
2ea2ea |
index 16c2f4f1a..b2302baa3 100644
|
|
|
2ea2ea |
--- a/m4/python.m4
|
|
|
2ea2ea |
+++ b/m4/python.m4
|
|
|
2ea2ea |
@@ -1,7 +1,7 @@
|
|
|
2ea2ea |
## ------------------------ -*- Autoconf -*-
|
|
|
2ea2ea |
## Python file handling
|
|
|
2ea2ea |
## From Andrew Dalke
|
|
|
2ea2ea |
-## Updated by James Henstridge
|
|
|
2ea2ea |
+## Updated by James Henstridge and other contributors.
|
|
|
2ea2ea |
## ------------------------
|
|
|
2ea2ea |
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
|
|
2ea2ea |
#
|
|
|
2ea2ea |
@@ -86,12 +86,14 @@ AC_DEFUN([AM_PATH_PYTHON],
|
|
|
2ea2ea |
m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
|
|
|
2ea2ea |
else
|
|
|
2ea2ea |
|
|
|
2ea2ea |
- dnl Query Python for its version number. Getting [:3] seems to be
|
|
|
2ea2ea |
- dnl the best way to do this; it's what "site.py" does in the standard
|
|
|
2ea2ea |
- dnl library.
|
|
|
2ea2ea |
+ dnl Query Python for its version number. Although site.py simply uses
|
|
|
2ea2ea |
+ dnl sys.version[:3], printing that failed with Python 3.10, since the
|
|
|
2ea2ea |
+ dnl trailing zero was eliminated. So now we output just the major
|
|
|
2ea2ea |
+ dnl and minor version numbers, as numbers. Apparently the tertiary
|
|
|
2ea2ea |
+ dnl version is not of interest.
|
|
|
2ea2ea |
|
|
|
2ea2ea |
AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
|
|
|
2ea2ea |
- [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
|
|
|
2ea2ea |
+ [am_cv_python_version=`$PYTHON -c "import sys; print('%u.%u' % sys.version_info[[:2]])"`])
|
|
|
2ea2ea |
AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
|
|
|
2ea2ea |
|
|
|
2ea2ea |
dnl Use the values of $prefix and $exec_prefix for the corresponding
|
|
|
2ea2ea |
diff --git a/t/python-vars.sh b/t/python-vars.sh
|
|
|
2ea2ea |
index 5c748bcf1..b53018b37 100644
|
|
|
2ea2ea |
--- a/t/python-vars.sh
|
|
|
2ea2ea |
+++ b/t/python-vars.sh
|
|
|
2ea2ea |
@@ -28,7 +28,9 @@ CONFIG_SITE=/dev/null; export CONFIG_SITE
|
|
|
2ea2ea |
# vary among different python installations, so we need more relaxed
|
|
|
2ea2ea |
# and ad-hoc checks for them. Also, more proper "functional" checks
|
|
|
2ea2ea |
# on them should be done in the 'python-virtualenv.sh' test.
|
|
|
2ea2ea |
-PYTHON_VERSION=$($PYTHON -c 'import sys; print(sys.version[:3])') || exit 1
|
|
|
2ea2ea |
+#
|
|
|
2ea2ea |
+# This version identification is duplicated in python.m4 (and the manual).
|
|
|
2ea2ea |
+PYTHON_VERSION=$($PYTHON -c 'import sys; print("%u.%u" % sys.version_info[:2])') || exit 1
|
|
|
2ea2ea |
PYTHON_PLATFORM=$($PYTHON -c 'import sys; print(sys.platform)') || exit 1
|
|
|
2ea2ea |
PYTHON_EXEC_PREFIX='${exec_prefix}'
|
|
|
2ea2ea |
PYTHON_PREFIX='${prefix}'
|
|
|
2ea2ea |
--
|
|
|
2ea2ea |
2.29.0
|
|
|
2ea2ea |
|