Fix support for python3.1x detection

Backporting 2 patches from upstream.
The first patch enable automake to look for python versions with
multiple digits when auto-detecting the default system python
interpreter version. The second allows automake to properly pick
automake version (up to python 3.15) when it was specified by the user
and yet different from the default system interpreter.

Resolves: rhbz#2209821
This commit is contained in:
Frédéric Bérat 2023-06-28 11:09:26 +02:00
parent 90db250214
commit 520aa7fdb7
3 changed files with 131 additions and 1 deletions

View File

@ -0,0 +1,37 @@
From 930a9a73f4bb776ec334eff4cf6e182802841daa Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Wed, 26 Jan 2022 06:33:19 -0500
Subject: [PATCH] python: add 3.10 - 3.15 to the version search list
Fixes automake bug https://bugs.gnu.org/53530.
Based on the cadence of Automake releases, add the current Python
release (3.10), the current Python development (3.11), and then 4
more versions on top of that. It doesn't hurt to check for a few
extra versions here since this is the fallback logic when the main
`python` and `python3` programs aren't found.
* m4/python.m4: Add python3.10 - python3.15.
* NEWS: Mention new Python versions.
Conflicts:
- NEWS (removed)
---
m4/python.m4 | 1 +
1 file changed, 1 insertion(+)
diff --git a/m4/python.m4 b/m4/python.m4
index 4a007fd75..4bf72286a 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -38,6 +38,7 @@ AC_DEFUN([AM_PATH_PYTHON],
dnl supported. (2.0 was released on October 16, 2000).
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
[python python2 python3 dnl
+ python3.15 python3.14 python3.13 python3.12 python3.11 python3.10 dnl
python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 dnl
python3.2 python3.1 python3.0 dnl
python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 dnl
--
2.41.0

View File

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

View File

@ -11,7 +11,7 @@
Summary: A GNU tool for automatically creating Makefiles Summary: A GNU tool for automatically creating Makefiles
Name: automake Name: automake
Version: %{api_version}.1 Version: %{api_version}.1
Release: 7%{?dist} Release: 8%{?dist}
# docs ~> GFDL, sources ~> GPLv2+, mkinstalldirs ~> PD and install-sh ~> MIT # docs ~> GFDL, sources ~> GPLv2+, mkinstalldirs ~> PD and install-sh ~> MIT
License: GPLv2+ and GFDL and Public Domain and MIT License: GPLv2+ and GFDL and Public Domain and MIT
@ -32,6 +32,10 @@ Patch0: automake-1.15-disable-vala-tests.patch
# http://git.savannah.gnu.org/cgit/automake.git/commit/?id=a348d830659fffd2cfc42994524783b07e69b4b5 # http://git.savannah.gnu.org/cgit/automake.git/commit/?id=a348d830659fffd2cfc42994524783b07e69b4b5
Patch1: automake-1.16-pep3147-tweak-fix.patch Patch1: automake-1.16-pep3147-tweak-fix.patch
# BZ#2209821
# Backport fixes for automake bugs 44239 and 53530
Patch2: automake-1.16.1-python-version-multiple-digits.patch
Patch3: 0001-python-add-3.10-3.15-to-the-version-search-list.patch
URL: http://www.gnu.org/software/automake/ URL: http://www.gnu.org/software/automake/
Requires: autoconf >= 2.65 Requires: autoconf >= 2.65
@ -128,6 +132,9 @@ make -k %{?_smp_mflags} check %{?TESTS_FLAGS: TESTS="%{TESTS_FLAGS}"} \
%changelog %changelog
* Wed Jun 28 2023 Frederic Berat <fberat@redhat.com> - 1.16.1-8
- Fix support for detection of python 3.1x (RHBZ#2209821)
* Tue May 05 2020 Patrik Novotný <panovotn@redhat.com> - 1.16.1-7 * Tue May 05 2020 Patrik Novotný <panovotn@redhat.com> - 1.16.1-7
- Upstream patch fixing automake bug#31222 - Upstream patch fixing automake bug#31222