Message ID | 20221102140039.914518-4-jwcart2@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Remove dependency on the Python module distutils | expand |
James Carter <jwcart2@gmail.com> writes: > The distutils package is deprecated and scheduled to be removed in > Python 3.12. Use the setuptools and sysconfig modules instead. > > Signed-off-by: James Carter <jwcart2@gmail.com> > --- > v2: Use sysconfig.get_path('purelib'... since original used > get_python_lib(prefix=... instead of > get_python_lib(plat_specific=1, prefix=... > > python/semanage/Makefile | 2 +- > python/sepolgen/src/sepolgen/Makefile | 2 +- > python/sepolicy/sepolicy/gui.py | 2 +- > python/sepolicy/setup.py | 2 +- > 4 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/python/semanage/Makefile b/python/semanage/Makefile > index 024e9640..b53ee33d 100644 > --- a/python/semanage/Makefile > +++ b/python/semanage/Makefile > @@ -5,7 +5,7 @@ LINGUAS ?= ru > PREFIX ?= /usr > SBINDIR ?= $(PREFIX)/sbin > MANDIR = $(PREFIX)/share/man > -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))") > +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '$(PREFIX)', 'base': '$(PREFIX)'}))") > PACKAGEDIR ?= $(PYTHONLIBDIR) > BASHCOMPLETIONDIR ?= $(PREFIX)/share/bash-completion/completions > > diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile > index cac8def7..a1039227 100644 > --- a/python/sepolgen/src/sepolgen/Makefile > +++ b/python/sepolgen/src/sepolgen/Makefile > @@ -1,6 +1,6 @@ > PREFIX ?= /usr > PYTHON ?= python3 > -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))") > +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '$(PREFIX)', 'base': '$(PREFIX)'}))") > PACKAGEDIR ?= /$(PYTHONLIBDIR)/sepolgen > > all: > diff --git a/python/sepolicy/sepolicy/gui.py b/python/sepolicy/sepolicy/gui.py > index 5bdbfeba..63f2371f 100644 > --- a/python/sepolicy/sepolicy/gui.py > +++ b/python/sepolicy/sepolicy/gui.py > @@ -77,7 +77,7 @@ def cmp(a, b): > return 1 > return (a > b) - (a < b) > > -import distutils.sysconfig > +import sysconfig CI https://github.com/bachradsusi/SELinuxProject-selinux/actions/runs/3384927657/jobs/5622477533 reports: Analyzing 118 Python scripts ./python/sepolicy/build/lib/sepolicy/gui.py:133:26: F821 undefined name 'distutils' ./python/sepolicy/sepolicy/gui.py:133:26: F821 undefined name 'distutils' Error: Process completed with exit code 1. The following patch makes the CI happy: --- a/python/sepolicy/sepolicy/gui.py +++ b/python/sepolicy/sepolicy/gui.py @@ -130,7 +130,7 @@ class SELinuxGui(): self.application = app self.filter_txt = "" builder = Gtk.Builder() # BUILDER OBJ - self.code_path = distutils.sysconfig.get_python_lib(plat_specific=False) + "/sepolicy/" + self.code_path = sysconfig.get_python_lib(plat_specific=False) + "/sepolicy/" > ADVANCED_LABEL = (_("Advanced >>"), _("Advanced <<")) > ADVANCED_SEARCH_LABEL = (_("Advanced Search >>"), _("Advanced Search <<")) > OUTBOUND_PAGE = 0 > diff --git a/python/sepolicy/setup.py b/python/sepolicy/setup.py > index b0f9650d..c8220664 100644 > --- a/python/sepolicy/setup.py > +++ b/python/sepolicy/setup.py > @@ -2,7 +2,7 @@ > > # Author: Thomas Liu <tliu@redhat.com> > # Author: Dan Walsh <dwalsh@redhat.com> > -from distutils.core import setup > +from setuptools import setup > > setup( > name="sepolicy", > -- > 2.38.1
diff --git a/python/semanage/Makefile b/python/semanage/Makefile index 024e9640..b53ee33d 100644 --- a/python/semanage/Makefile +++ b/python/semanage/Makefile @@ -5,7 +5,7 @@ LINGUAS ?= ru PREFIX ?= /usr SBINDIR ?= $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))") +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '$(PREFIX)', 'base': '$(PREFIX)'}))") PACKAGEDIR ?= $(PYTHONLIBDIR) BASHCOMPLETIONDIR ?= $(PREFIX)/share/bash-completion/completions diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile index cac8def7..a1039227 100644 --- a/python/sepolgen/src/sepolgen/Makefile +++ b/python/sepolgen/src/sepolgen/Makefile @@ -1,6 +1,6 @@ PREFIX ?= /usr PYTHON ?= python3 -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))") +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '$(PREFIX)', 'base': '$(PREFIX)'}))") PACKAGEDIR ?= /$(PYTHONLIBDIR)/sepolgen all: diff --git a/python/sepolicy/sepolicy/gui.py b/python/sepolicy/sepolicy/gui.py index 5bdbfeba..63f2371f 100644 --- a/python/sepolicy/sepolicy/gui.py +++ b/python/sepolicy/sepolicy/gui.py @@ -77,7 +77,7 @@ def cmp(a, b): return 1 return (a > b) - (a < b) -import distutils.sysconfig +import sysconfig ADVANCED_LABEL = (_("Advanced >>"), _("Advanced <<")) ADVANCED_SEARCH_LABEL = (_("Advanced Search >>"), _("Advanced Search <<")) OUTBOUND_PAGE = 0 diff --git a/python/sepolicy/setup.py b/python/sepolicy/setup.py index b0f9650d..c8220664 100644 --- a/python/sepolicy/setup.py +++ b/python/sepolicy/setup.py @@ -2,7 +2,7 @@ # Author: Thomas Liu <tliu@redhat.com> # Author: Dan Walsh <dwalsh@redhat.com> -from distutils.core import setup +from setuptools import setup setup( name="sepolicy",
The distutils package is deprecated and scheduled to be removed in Python 3.12. Use the setuptools and sysconfig modules instead. Signed-off-by: James Carter <jwcart2@gmail.com> --- v2: Use sysconfig.get_path('purelib'... since original used get_python_lib(prefix=... instead of get_python_lib(plat_specific=1, prefix=... python/semanage/Makefile | 2 +- python/sepolgen/src/sepolgen/Makefile | 2 +- python/sepolicy/sepolicy/gui.py | 2 +- python/sepolicy/setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)