From 4dc82e9d503518a00e54972be7c0cb5f342f985e Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Tue, 8 Jun 2021 20:20:16 -0400 Subject: [PATCH] Correct a flaw in the Python 3 version checking It turns out the ax_python_devel.m4 version check assumes that ("3.X+1.0" >= "3.X.0") is True in Python, which is not when X+1 is 10 or above and X is not. (Also presumably X+1=100 and ...) So let's remake the check to behave consistently, using the "packaging" or (if absent) the "distlib" modules. (Also, update the Github workflows to use the new packages.) Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Rich Ercolani Closes: #12073 (cherry picked from commit 08cd0717359b1a18693e3c8e6d6e5a2819b35a48) [Romain: drop rpm spec and github workflows changes] Signed-off-by: Romain Naour --- config/always-pyzfs.m4 | 15 +++++++++++++++ config/ax_python_devel.m4 | 33 +++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/config/always-pyzfs.m4 b/config/always-pyzfs.m4 index 76e07b593..fa39fd885 100644 --- a/config/always-pyzfs.m4 +++ b/config/always-pyzfs.m4 @@ -46,6 +46,21 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYZFS], [ ]) AC_SUBST(DEFINE_PYZFS) + dnl # + dnl # Python "packaging" (or, failing that, "distlib") module is required to build and install pyzfs + dnl # + AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [ + ZFS_AC_PYTHON_MODULE([packaging], [], [ + ZFS_AC_PYTHON_MODULE([distlib], [], [ + AS_IF([test "x$enable_pyzfs" = xyes], [ + AC_MSG_ERROR("Python $PYTHON_VERSION packaging and distlib modules are not installed") + ], [test "x$enable_pyzfs" != xno], [ + enable_pyzfs=no + ]) + ]) + ]) + ]) + dnl # dnl # Require python-devel libraries dnl # diff --git a/config/ax_python_devel.m4 b/config/ax_python_devel.m4 index c51b45b7d..cdfbbf81f 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<= '3.11.0' + ac_supports_python_ver=`cat<