Remove dependency on the Python module distutils
v3 cover Remove dependency on the Python module distutils
The distutils package is deprecated and scheduled to be removed in Python 3.12.
When building the SELinux userspace we currently get warnings like the following:
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
I am not a Python expert, but everything seems to work with these patches. I would appreciate other people testing this and any Python experts to let me know if this is the right way of replacing distutils.
v3: Removed a second usage of distutils in python/sepolicy/sepolicy/gui.py
v2: Use sysconfig.get_path('purelib'... when original used
get_python_lib(prefix=... and use sysconfig.get_path('platlib'... when original used get_python_lib(plat_specific=1, prefix=...
James Carter (5):
libselinux: Remove dependency on the Python module distutils
libsemanage: Remove dependency on the Python module distutils
python: Remove dependency on the Python module distutils
scripts: Remove dependency on the Python module distutils README.md: Remove mention of python3-distutils dependency
README.md | 1 - libselinux/src/Makefile | 2 +- libselinux/src/setup.py | 2 +- libsemanage/src/Makefile | 2 +- python/semanage/Makefile | 2 +- python/sepolgen/src/sepolgen/Makefile | 2 +- python/sepolicy/sepolicy/gui.py | 4 ++-- python/sepolicy/setup.py | 2 +- scripts/env_use_destdir | 2 +- scripts/run-scan-build | 2 +- 10 files changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.38.1
PATCH v3 1/5 libselinux: Remove dependency on the Python module distutils
The distutils package is deprecated and scheduled to be removed in Python 3.12. Use the setuptools and sysconfig modules instead.
--- libselinux/src/Makefile | 2 +- libselinux/src/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
libselinux/src/Makefile +1 -1
@@ -14,7 +14,7 @@ SHLIBDIR ?= /lib INCLUDEDIR ?= $(PREFIX)/include PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX)) PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX)) -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(plat_specific=1, prefix='$(PREFIX)'))") +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '$(PREFIX)', 'base': '$(PREFIX)'}))") PYCEXT ?= $(shell $(PYTHON) -c 'import importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES[0])') RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]') RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
libselinux/src/setup.py +1 -1
@@ -1,6 +1,6 @@ #!/usr/bin/python3 -from distutils.core import Extension, setup +from setuptools import Extension, setup setup( name="selinux",
Signature · 1 line
2.38.1
PATCH v3 2/5 libsemanage: Remove dependency on the Python module distutils
In reply to James CarterThe distutils package is deprecated and scheduled to be removed in Python 3.12. Use the sysconfig module instead.
--- libsemanage/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/Makefile +1 -1
@@ -14,7 +14,7 @@ INCLUDEDIR ?= $(PREFIX)/include SYSCONFDIR ?= /etc PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX)) PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX)) -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(plat_specific=1, prefix='$(PREFIX)'))") +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '$(PREFIX)', 'base': '$(PREFIX)'}))") PYCEXT ?= $(shell $(PYTHON) -c 'import importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES[0])') RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]') RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
Signature · 1 line
2.38.1
PATCH v3 3/5 python: Remove dependency on the Python module distutils
In reply to James CarterThe distutils package is deprecated and scheduled to be removed in Python 3.12. Use the setuptools and sysconfig modules instead.
---
v3: Removed another usage of distutils in gui.py
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 | 4 ++-- python/sepolicy/setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
python/semanage/Makefile +1 -1
@@ -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
python/sepolgen/src/sepolgen/Makefile +1 -1
@@ -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:
python/sepolicy/sepolicy/gui.py +2 -2
@@ -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
@@ -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/" glade_file = self.code_path + "sepolicy.glade" builder.add_from_file(glade_file) self.outer_notebook = builder.get_object("outer_notebook")
python/sepolicy/setup.py +1 -1
@@ -2,7 +2,7 @@ # Author: Thomas Liu <[email protected]> # Author: Dan Walsh <[email protected]> -from distutils.core import setup +from setuptools import setup setup( name="sepolicy",
Signature · 1 line
2.38.1
PATCH v3 4/5 scripts: Remove dependency on the Python module distutils
In reply to James CarterThe distutils package is deprecated and scheduled to be removed in Python 3.12. Use the sysconfig module instead.
--- scripts/env_use_destdir | 2 +- scripts/run-scan-build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
scripts/env_use_destdir +1 -1
@@ -43,7 +43,7 @@ if [ -n "${SBINDIR:-}" ] ; then PATH="$DESTDIR$SBINDIR:$PATH" fi -NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(plat_specific=1, prefix='/usr'))"):$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" +NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '/usr', 'base': '/usr'}))"):$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")" if [ -n "${PYTHONPATH:-}" ] ; then # Prefix the PYTHONPATH with the new directories export PYTHONPATH="$NEW_PYTHONPATH:$PYTHONPATH"
scripts/run-scan-build +1 -1
@@ -21,7 +21,7 @@ fi # Make sure to use the newly-installed libraries when running tests export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib" export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH" -export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" +export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")" export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')" if [ -f /etc/debian_version ] && [ -z "${IS_CIRCLE_CI:-}" ] ; then
Signature · 1 line
2.38.1
PATCH v3 5/5 README.md: Remove mention of python3-distutils dependency
In reply to James CarterWith the removal of any dependence on the python disutils module, Debian no longer depends on the python3-disutils package.
--- README.md | 1 - 1 file changed, 1 deletion(-)
README.md +0 -1
@@ -81,7 +81,6 @@ apt-get install --no-install-recommends --no-install-suggests \ libpcre2-dev \ pkgconf \ python3 \ - python3-distutils \ systemd \ xmlto
Signature · 1 line
2.38.1
Quoted 17 lines · James Carter
The distutils package is deprecated and scheduled to be removed in Python 3.12.
When building the SELinux userspace we currently get warnings like the following:
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternativesI am not a Python expert, but everything seems to work with these patches. I would appreciate other people testing this and any Python experts to let me know if this is the right way of replacing distutils.
v3: Removed a second usage of distutils in
python/sepolicy/sepolicy/gui.pyv2: Use sysconfig.get_path('purelib'... when original used
get_python_lib(prefix=... and use sysconfig.get_path('platlib'... when original used get_python_lib(plat_specific=1, prefix=...
Quoted 6 lines
James Carter (5):
libselinux: Remove dependency on the Python module distutils
libsemanage: Remove dependency on the Python module distutils
python: Remove dependency on the Python module distutils
scripts: Remove dependency on the Python module distutils README.md: Remove mention of python3-distutils dependency
Quoted 14 lines
README.md | 1 - libselinux/src/Makefile | 2 +- libselinux/src/setup.py | 2 +- libsemanage/src/Makefile | 2 +- python/semanage/Makefile | 2 +- python/sepolgen/src/sepolgen/Makefile | 2 +- python/sepolicy/sepolicy/gui.py | 4 ++-- python/sepolicy/setup.py | 2 +- scripts/env_use_destdir | 2 +- scripts/run-scan-build | 2 +- 10 files changed, 10 insertions(+), 11 deletions(-)Signature · 1 line
2.38.1
Quoted 20 lines · Petr Lautrbach
Quoted 17 lines · James Carter
The distutils package is deprecated and scheduled to be removed in Python 3.12.
When building the SELinux userspace we currently get warnings like the following:
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternativesI am not a Python expert, but everything seems to work with these patches. I would appreciate other people testing this and any Python experts to let me know if this is the right way of replacing distutils.
v3: Removed a second usage of distutils in
python/sepolicy/sepolicy/gui.pyv2: Use sysconfig.get_path('purelib'... when original used
get_python_lib(prefix=... and use sysconfig.get_path('platlib'... when original used get_python_lib(plat_specific=1, prefix=...
Quoted 9 lines
Quoted 6 lines
James Carter (5):
libselinux: Remove dependency on the Python module distutils
libsemanage: Remove dependency on the Python module distutils
python: Remove dependency on the Python module distutils
scripts: Remove dependency on the Python module distutils README.md: Remove mention of python3-distutils dependencyAcked-by Petr Lautrbach <[email protected]>
This series has been merged.
Jim
Quoted 16 lines
Quoted 15 lines
README.md | 1 - libselinux/src/Makefile | 2 +- libselinux/src/setup.py | 2 +- libsemanage/src/Makefile | 2 +- python/semanage/Makefile | 2 +- python/sepolgen/src/sepolgen/Makefile | 2 +- python/sepolicy/sepolicy/gui.py | 4 ++-- python/sepolicy/setup.py | 2 +- scripts/env_use_destdir | 2 +- scripts/run-scan-build | 2 +- 10 files changed, 10 insertions(+), 11 deletions(-)--
2.38.1