diff options
author | Rich Ercolani <[email protected]> | 2021-06-08 20:20:16 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-08 18:20:16 -0600 |
commit | 08cd0717359b1a18693e3c8e6d6e5a2819b35a48 (patch) | |
tree | 457539fe667ab977e5ff9e022c84a0aa1ef33996 | |
parent | 1fcfc21cd8cce3d44b2526f262be5c73e4d8621a (diff) |
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 <[email protected]>
Reviewed-by: John Kennedy <[email protected]>
Signed-off-by: Rich Ercolani <[email protected]>
Closes: #12073
-rw-r--r-- | .github/workflows/zfs-tests-functional.yml | 3 | ||||
-rw-r--r-- | .github/workflows/zfs-tests-sanity.yml | 3 | ||||
-rw-r--r-- | .github/workflows/zloop.yml | 4 | ||||
-rw-r--r-- | config/always-pyzfs.m4 | 15 | ||||
-rw-r--r-- | config/ax_python_devel.m4 | 33 | ||||
-rw-r--r-- | rpm/generic/zfs.spec.in | 5 |
6 files changed, 53 insertions, 10 deletions
diff --git a/.github/workflows/zfs-tests-functional.yml b/.github/workflows/zfs-tests-functional.yml index d2b5764db..eacc95ae1 100644 --- a/.github/workflows/zfs-tests-functional.yml +++ b/.github/workflows/zfs-tests-functional.yml @@ -26,7 +26,8 @@ jobs: xfslibs-dev libattr1-dev libacl1-dev libudev-dev libdevmapper-dev \ libssl-dev libffi-dev libaio-dev libelf-dev libmount-dev \ libpam0g-dev pamtester python-dev python-setuptools python-cffi \ - python3 python3-dev python3-setuptools python3-cffi libcurl4-openssl-dev + python-packaging python3 python3-dev python3-setuptools python3-cffi \ + libcurl4-openssl-dev python3-packaging - name: Autogen.sh run: | sh autogen.sh diff --git a/.github/workflows/zfs-tests-sanity.yml b/.github/workflows/zfs-tests-sanity.yml index 9e2ed1b2f..40a7f8ba5 100644 --- a/.github/workflows/zfs-tests-sanity.yml +++ b/.github/workflows/zfs-tests-sanity.yml @@ -22,7 +22,8 @@ jobs: xfslibs-dev libattr1-dev libacl1-dev libudev-dev libdevmapper-dev \ libssl-dev libffi-dev libaio-dev libelf-dev libmount-dev \ libpam0g-dev pamtester python-dev python-setuptools python-cffi \ - python3 python3-dev python3-setuptools python3-cffi libcurl4-openssl-dev + python-packaging python3 python3-dev python3-setuptools python3-cffi \ + python3-packaging libcurl4-openssl-dev - name: Autogen.sh run: | sh autogen.sh diff --git a/.github/workflows/zloop.yml b/.github/workflows/zloop.yml index 30785b145..b3679e7f7 100644 --- a/.github/workflows/zloop.yml +++ b/.github/workflows/zloop.yml @@ -22,8 +22,8 @@ jobs: xfslibs-dev libattr1-dev libacl1-dev libudev-dev libdevmapper-dev \ libssl-dev libffi-dev libaio-dev libelf-dev libmount-dev \ libpam0g-dev \ - python-dev python-setuptools python-cffi \ - python3 python3-dev python3-setuptools python3-cffi + python-dev python-setuptools python-cffi python-packaging \ + python3 python3-dev python3-setuptools python3-cffi python3-packaging - name: Autogen.sh run: | sh autogen.sh 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 @@ -47,6 +47,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 # AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [ 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 diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in index b1750942f..b073d68a4 100644 --- a/rpm/generic/zfs.spec.in +++ b/rpm/generic/zfs.spec.in @@ -306,6 +306,11 @@ Requires: libffi Requires: python%{__python_pkg_version} Requires: %{__python_cffi_pkg} %if 0%{?rhel}%{?fedora}%{?suse_version} +%if 0%{?rhel} >= 8 || 0%{?centos} >= 8 || 0%{?fedora} >= 28 +BuildRequires: python3-packaging +%else +BuildRequires: python-packaging +%endif BuildRequires: python%{__python_pkg_version}-devel BuildRequires: %{__python_cffi_pkg} BuildRequires: %{__python_setuptools_pkg} |