1From ad95b7684365dea8335c34527d4c1463c1668af0 Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz> 3Date: Fri, 31 Mar 2023 14:52:19 +0200 4Subject: [PATCH] Use setuptools instead of distutils 5 6distutils is removed from Python 3.12+: 7https://peps.python.org/pep-0632/ 8 9Upstream-Status: Backport [https://github.com/libpwquality/libpwquality/commit/7b5e0f0097faebdcc6a8b783237bbba7a983147a] 10Signed-off-by: Alexander Kanavin <alex@linutronix.de> 11--- 12 libpwquality.spec.in | 11 ++--------- 13 python/Makefile.am | 2 +- 14 python/setup.py.in | 6 +++--- 15 3 files changed, 6 insertions(+), 13 deletions(-) 16 17diff --git a/libpwquality.spec.in b/libpwquality.spec.in 18index 70a6f53..0809126 100644 19--- a/libpwquality.spec.in 20+++ b/libpwquality.spec.in 21@@ -33,9 +33,11 @@ BuildRequires: gettext 22 BuildRequires: pam-devel 23 %if %{with python2} 24 BuildRequires: python2-devel 25+BuildRequires: python2-setuptools 26 %endif 27 %if %{with python3} 28 BuildRequires: python3-devel 29+BuildRequires: python3-setuptools 30 %endif 31 32 URL: https://github.com/libpwquality/libpwquality/ 33@@ -103,15 +105,6 @@ cp -a . %{py3dir} 34 pushd %{py3dir} 35 %endif 36 %if %{with python3} 37-# setuptools >= 60 changes the environment to use its bundled copy of distutils 38-# by default, not the Python-bundled one. To run the Python's standard library 39-# distutils, the environment variable must be set. 40-# Although technically setuptools is not needed for this package, if it's 41-# pulled by another package, it changes the environment and consequently, 42-# the build fails. This was reported in: 43-# https://github.com/pypa/setuptools/issues/3143 44-export SETUPTOOLS_USE_DISTUTILS=stdlib 45- 46 %configure \ 47 --with-securedir=%{_moduledir} \ 48 --with-pythonsitedir=%{python3_sitearch} \ 49diff --git a/python/Makefile.am b/python/Makefile.am 50index 1d00c0c..6e51744 100644 51--- a/python/Makefile.am 52+++ b/python/Makefile.am 53@@ -14,7 +14,7 @@ all-local: 54 CFLAGS="${CFLAGS} -fno-strict-aliasing" @PYTHONBINARY@ setup.py build --build-base py$(PYTHONREV) 55 56 install-exec-local: 57- CFLAGS="${CFLAGS} -fno-strict-aliasing" @PYTHONBINARY@ setup.py build --build-base py$(PYTHONREV) install --prefix=${DESTDIR}${prefix} 58+ CFLAGS="${CFLAGS} -fno-strict-aliasing" @PYTHONBINARY@ setup.py build --build-base py$(PYTHONREV) install --root ${DESTDIR} --prefix=${prefix} 59 60 clean-local: 61 rm -rf py$(PYTHONREV) 62diff --git a/python/setup.py.in b/python/setup.py.in 63index a741b91..f934c50 100755 64--- a/python/setup.py.in 65+++ b/python/setup.py.in 66@@ -6,9 +6,9 @@ 67 68 import os 69 70-from distutils.core import setup, Extension 71-from distutils.command.build_ext import build_ext as _build_ext 72-from distutils.command.sdist import sdist as _sdist 73+from setuptools import setup, Extension 74+from setuptools.command.build_ext import build_ext as _build_ext 75+from setuptools.command.sdist import sdist as _sdist 76 77 def genconstants(headerfile, outputfile): 78 hf = open(headerfile, 'r') 79