From 6bf2ec6727a6413985ab23949fb096a83bcbe15f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 3 Jan 2023 13:29:46 +0000 Subject: [PATCH] Fix for Python 3.12 distutils change (RHBZ#2152674). --- ...-ublk-Update-for-ubdsrv-changing-API.patch | 2 +- ...eplace-Python-distutils-by-sysconfig.patch | 54 +++++++++++++++++++ libnbd.spec | 8 ++- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 0002-build-Replace-Python-distutils-by-sysconfig.patch diff --git a/0001-ublk-Update-for-ubdsrv-changing-API.patch b/0001-ublk-Update-for-ubdsrv-changing-API.patch index 2de839b..2355e0b 100644 --- a/0001-ublk-Update-for-ubdsrv-changing-API.patch +++ b/0001-ublk-Update-for-ubdsrv-changing-API.patch @@ -1,7 +1,7 @@ From 7a402ab853f480245767d72ae2f61e880893ea4d Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Fri, 9 Dec 2022 13:45:01 +0000 -Subject: [PATCH] ublk: Update for ubdsrv changing API +Subject: [PATCH 1/2] ublk: Update for ubdsrv changing API See: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/NKQKUCUOHDCVVSR2PXVANGZSBXXPHYLY/ diff --git a/0002-build-Replace-Python-distutils-by-sysconfig.patch b/0002-build-Replace-Python-distutils-by-sysconfig.patch new file mode 100644 index 0000000..348c0c1 --- /dev/null +++ b/0002-build-Replace-Python-distutils-by-sysconfig.patch @@ -0,0 +1,54 @@ +From 8c802dd9459f695ab2195f7b29fbe71c65c33a81 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 18 Oct 2022 10:55:22 +0100 +Subject: [PATCH 2/2] build: Replace Python distutils by sysconfig +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This module has been deprecated in Python >= 3.10 +(https://peps.python.org/pep-0632/). Replace distutils.sysconfig with +sysconfig which is not quite a drop-in replacement. + +This fix is incomplete as we still reference distutils in +python/setup.py.in. However that is only used for PIP-style +distributions (make -C python sdist) which we don't really use or +recommend. + +Thanks: Miro HronĨok +See-also: https://peps.python.org/pep-0632/ +See-also: https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/N6ITYHLRWIDNYNXGPYG2ZHF3ZLQWZN7L/ + +Cherry picked from libguestfs commit 26940f64a7406761 +--- + configure.ac | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 3a09816af7..5f0ca6994d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -549,16 +549,16 @@ AS_IF([test "x$enable_python" != "xno"],[ + PYTHON_INSTALLDIR= + AC_MSG_CHECKING([for Python site-packages path]) + if test -z "$PYTHON_INSTALLDIR"; then +- PYTHON_INSTALLDIR=`$PYTHON -c "import distutils.sysconfig; \ +- print (distutils.sysconfig.get_python_lib(1,0));"` ++ PYTHON_INSTALLDIR=`$PYTHON -c "import sysconfig; \ ++ print (sysconfig.get_path('platlib'));"` + fi + AC_MSG_RESULT([$PYTHON_INSTALLDIR]) + fi + + AC_MSG_CHECKING([for Python extension suffix (PEP-3149)]) + if test -z "$PYTHON_EXT_SUFFIX"; then +- python_ext_suffix=`$PYTHON -c "import distutils.sysconfig; \ +- print (distutils.sysconfig.get_config_var('EXT_SUFFIX') or distutils.sysconfig.get_config_var('SO'))"` ++ python_ext_suffix=`$PYTHON -c "import sysconfig; \ ++ print (sysconfig.get_config_var('EXT_SUFFIX') or sysconfig.get_config_var('SO'))"` + PYTHON_EXT_SUFFIX=$python_ext_suffix + fi + AC_MSG_RESULT([$PYTHON_EXT_SUFFIX]) +-- +2.37.3 + diff --git a/libnbd.spec b/libnbd.spec index e942601..6bc4b26 100644 --- a/libnbd.spec +++ b/libnbd.spec @@ -12,7 +12,7 @@ Name: libnbd Version: 1.15.8 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NBD client library in userspace License: LGPLv2+ @@ -31,6 +31,9 @@ Source3: copy-patches.sh # Upstream fix for changed ubdsrv API. Patch: 0001-ublk-Update-for-ubdsrv-changing-API.patch +# Upstream Python change (RHBZ#2152674). +Patch: 0002-build-Replace-Python-distutils-by-sysconfig.patch + %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool %endif @@ -349,6 +352,9 @@ make %{?_smp_mflags} check || { %changelog +* Tue Jan 03 2023 Richard W.M. Jones - 1.15.8-3 +- Fix for Python 3.12 distutils change (RHBZ#2152674). + * Fri Dec 09 2022 Richard W.M. Jones - 1.15.8-2 - Rebuild against new ubdsrv API