void-packages/srcpkgs/zfs/patches/python310.patch
2021-10-09 08:01:11 -04:00

92 lines
3.1 KiB
Diff

Most fo the patch taken from
https://github.com/openzfs/zfs/commit/08cd0717359b1a18693e3c8e6d6e5a2819b35a48
but this fix still missed the `print (sys.version[[:3]])"` part of the test,
which extracts "3.1" on Python 3.10. The right fix is to properly split
sys.version on '.' and rejoin the first two components.
diff -ur a/config/always-pyzfs.m4 b/config/always-pyzfs.m4
--- a/config/always-pyzfs.m4 2021-09-15 16:30:47.164862738 -0400
+++ b/config/always-pyzfs.m4 2021-09-29 14:34:51.288636042 -0400
@@ -47,6 +47,21 @@
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 -ur a/config/ax_python_devel.m4 b/config/ax_python_devel.m4
--- a/config/ax_python_devel.m4 2021-09-15 16:30:47.164862738 -0400
+++ b/config/ax_python_devel.m4 2021-09-29 14:40:23.293455112 -0400
@@ -97,9 +97,18 @@
# 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 @@
#
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
@@ -203,7 +224,7 @@
ac_python_version=$PYTHON_VERSION
else
ac_python_version=`$PYTHON -c "import sys; \
- print (sys.version[[:3]])"`
+ print ('.'.join(sys.version.split('.')[[:2]]))"`
fi
fi