[PATCH gpgme 2/2] build: Find correct version string for Python >= 3.10

Ben Greiner code at bnavigator.de
Thu Dec 23 16:37:13 CET 2021


* m4/python.m4: use version_info for Python 3.10 version string

--
Format sys.version_info[:2] instead of cutting it from sys.version[:3]
as Python versions >= 3.10 have more than 3 characters for their version
string. Bump minimum Python version to 2.1 because the new
ax_python_devel specifies this.
---
  configure.ac |  3 ++-
  m4/python.m4 | 15 +++++++--------
  2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4ce30677..bb124c54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -425,11 +425,12 @@ if test "$found_py" = "1"; then
  	if test "$found_py" = "1" -o "$found_py3" = "1"; then
  	  # Reset everything, so that we can look for another Python.
            m4_foreach([mym4pythonver],
-                     [[2.7],[3.4],[3.5],[3.6],[3.7],[3.8],[3.9],[all]],
+                     [[2.7],[3.4],[3.5],[3.6],[3.7],[3.8],[3.9],[3.10],[all]],
             [unset PYTHON
  	    unset PYTHON_VERSION
  	    unset PYTHON_CPPFLAGS
  	    unset PYTHON_LDFLAGS
+	    unset PYTHON_LIBS
  	    unset PYTHON_SITE_PKG
  	    unset PYTHON_EXTRA_LIBS
  	    unset PYTHON_EXTRA_LDFLAGS
diff --git a/m4/python.m4 b/m4/python.m4
index fd0fe771..5dfbeddb 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -36,13 +36,12 @@
  # numbers and dots only.
  AC_DEFUN([AM_PATH_PYTHON],
   [
-  dnl Find a Python interpreter.  Python versions prior to 2.0 are not
-  dnl supported. (2.0 was released on October 16, 2000).  Python 3.0
-  dnl through to Python 3.9 are also not supported.
+  dnl Find a Python interpreter.  Python versions prior to 2.1 are not
+  dnl supported. Python 3.0 through to Python 3.3 are also not supported.
    m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
  [python2 python2.7 dnl
   python dnl
- python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4
+ python3 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4
   ])
  
    AC_ARG_VAR([PYTHON], [the Python interpreter])
@@ -89,12 +88,12 @@ 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.  Formatting sys.version_info[:2]
+  dnl seems to be the most reliable way to do this across versions 2.1
+  dnl through 3.10; it's what "site.py" does in the standard 3.10 library.
  
    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; sys.stdout.write('%d.%d' % sys.version_info[[:2]])"`])
    AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
  
    dnl Use the values of $prefix and $exec_prefix for the corresponding
-- 2.34.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20211223/2d588087/attachment.sig>


More information about the Gnupg-devel mailing list