aboutsummaryrefslogtreecommitdiffstats
path: root/config/ax_python_devel.m4
diff options
context:
space:
mode:
Diffstat (limited to 'config/ax_python_devel.m4')
-rw-r--r--config/ax_python_devel.m433
1 files changed, 27 insertions, 6 deletions
diff --git a/config/ax_python_devel.m4 b/config/ax_python_devel.m4
index faf6c2b0d..fcf73dc20 100644
--- a/config/ax_python_devel.m4
+++ b/config/ax_python_devel.m4
@@ -97,9 +97,18 @@ AC_DEFUN([AX_PYTHON_DEVEL],[
# Check for a version of Python >= 2.1.0
#
AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
- ac_supports_python_ver=`$PYTHON -c "import sys; \
- ver = sys.version.split ()[[0]]; \
- print (ver >= '2.1.0')"`
+ ac_supports_python_ver=`cat<<EOD | $PYTHON -
+from __future__ import print_function;
+import sys;
+try:
+ from packaging import version;
+except ImportError:
+ from distlib import version;
+ver = sys.version.split ()[[0]];
+(tst_cmp, tst_ver) = ">= '2.1.0'".split ();
+tst_ver = tst_ver.strip ("'");
+eval ("print (version.LegacyVersion (ver)"+ tst_cmp +"version.LegacyVersion (tst_ver))")
+EOD`
if test "$ac_supports_python_ver" != "True"; then
if test -z "$PYTHON_NOVERSIONCHECK"; then
AC_MSG_RESULT([no])
@@ -126,9 +135,21 @@ to something else than an empty string.
#
if test -n "$1"; then
AC_MSG_CHECKING([for a version of Python $1])
- ac_supports_python_ver=`$PYTHON -c "import sys; \
- ver = sys.version.split ()[[0]]; \
- print (ver $1)"`
+ # Why the strip ()? Because if we don't, version.parse
+ # will, for example, report 3.10.0 >= '3.11.0'
+ ac_supports_python_ver=`cat<<EOD | $PYTHON -
+
+from __future__ import print_function;
+import sys;
+try:
+ from packaging import version;
+except ImportError:
+ from distlib import version;
+ver = sys.version.split ()[[0]];
+(tst_cmp, tst_ver) = "$1".split ();
+tst_ver = tst_ver.strip ("'");
+eval ("print (version.LegacyVersion (ver)"+ tst_cmp +"version.LegacyVersion (tst_ver))")
+EOD`
if test "$ac_supports_python_ver" = "True"; then
AC_MSG_RESULT([yes])
else