From 5ffa915c9c36956f4cd7ca304e363d2060dc38a2 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 16 Apr 2021 14:06:07 -0600 Subject: [PATCH] determine Python (3.10) version number correctly. from upstream automake --- configure | 2 +- m4/python.m4 | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/configure b/configure index d46c8025c..29c381183 100755 --- a/configure +++ b/configure @@ -19594,7 +19594,7 @@ if test ${am_cv_python_version+y} then : printf %s "(cached) " >&6 else $as_nop - 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])"` fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5 printf "%s\n" "$am_cv_python_version" >&6; } diff --git a/m4/python.m4 b/m4/python.m4 index 16c2f4f1a..b2302baa3 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-2020 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