All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5 v3] Remove dependency on the Python module distutils
@ 2022-11-04 14:36 James Carter
  2022-11-04 14:36 ` [PATCH 1/5 v3] libselinux: " James Carter
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: James Carter @ 2022-11-04 14:36 UTC (permalink / raw)
  To: selinux; +Cc: plautrba, 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 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(-)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/5 v3] libselinux: Remove dependency on the Python module distutils
  2022-11-04 14:36 [PATCH 0/5 v3] Remove dependency on the Python module distutils James Carter
@ 2022-11-04 14:36 ` James Carter
  2022-11-04 14:36 ` [PATCH 2/5 v3] libsemanage: " James Carter
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: James Carter @ 2022-11-04 14:36 UTC (permalink / raw)
  To: selinux; +Cc: plautrba, James Carter

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>
---
 libselinux/src/Makefile | 2 +-
 libselinux/src/setup.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 49b7d60a..dc284832 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -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"]')
diff --git a/libselinux/src/setup.py b/libselinux/src/setup.py
index 71e69a10..6cbe3a0e 100644
--- a/libselinux/src/setup.py
+++ b/libselinux/src/setup.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python3
 
-from distutils.core import Extension, setup
+from setuptools import Extension, setup
 
 setup(
     name="selinux",
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/5 v3] libsemanage: Remove dependency on the Python module distutils
  2022-11-04 14:36 [PATCH 0/5 v3] Remove dependency on the Python module distutils James Carter
  2022-11-04 14:36 ` [PATCH 1/5 v3] libselinux: " James Carter
@ 2022-11-04 14:36 ` James Carter
  2022-11-04 14:36 ` [PATCH 3/5] python: " James Carter
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: James Carter @ 2022-11-04 14:36 UTC (permalink / raw)
  To: selinux; +Cc: plautrba, James Carter

The distutils package is deprecated and scheduled to be removed in
Python 3.12. Use the sysconfig module instead.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsemanage/src/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index 01df0181..589e4a70 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -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"]')
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/5] python: Remove dependency on the Python module distutils
  2022-11-04 14:36 [PATCH 0/5 v3] Remove dependency on the Python module distutils James Carter
  2022-11-04 14:36 ` [PATCH 1/5 v3] libselinux: " James Carter
  2022-11-04 14:36 ` [PATCH 2/5 v3] libsemanage: " James Carter
@ 2022-11-04 14:36 ` James Carter
  2022-11-04 14:36 ` [PATCH 4/5 v3] scripts: " James Carter
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: James Carter @ 2022-11-04 14:36 UTC (permalink / raw)
  To: selinux; +Cc: plautrba, James Carter

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>
---
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(-)

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..335be582 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
@@ -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")
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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/5 v3] scripts: Remove dependency on the Python module distutils
  2022-11-04 14:36 [PATCH 0/5 v3] Remove dependency on the Python module distutils James Carter
                   ` (2 preceding siblings ...)
  2022-11-04 14:36 ` [PATCH 3/5] python: " James Carter
@ 2022-11-04 14:36 ` James Carter
  2022-11-04 14:36 ` [PATCH 5/5 v3] README.md: Remove mention of python3-distutils dependency James Carter
  2022-11-07  8:13 ` [PATCH 0/5 v3] Remove dependency on the Python module distutils Petr Lautrbach
  5 siblings, 0 replies; 8+ messages in thread
From: James Carter @ 2022-11-04 14:36 UTC (permalink / raw)
  To: selinux; +Cc: plautrba, James Carter

The distutils package is deprecated and scheduled to be removed in
Python 3.12. Use the sysconfig module instead.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 scripts/env_use_destdir | 2 +-
 scripts/run-scan-build  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/env_use_destdir b/scripts/env_use_destdir
index 8274013e..89d989a2 100755
--- a/scripts/env_use_destdir
+++ b/scripts/env_use_destdir
@@ -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"
diff --git a/scripts/run-scan-build b/scripts/run-scan-build
index 77e02ca9..931ffd2a 100755
--- a/scripts/run-scan-build
+++ b/scripts/run-scan-build
@@ -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
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/5 v3] README.md: Remove mention of python3-distutils dependency
  2022-11-04 14:36 [PATCH 0/5 v3] Remove dependency on the Python module distutils James Carter
                   ` (3 preceding siblings ...)
  2022-11-04 14:36 ` [PATCH 4/5 v3] scripts: " James Carter
@ 2022-11-04 14:36 ` James Carter
  2022-11-07  8:13 ` [PATCH 0/5 v3] Remove dependency on the Python module distutils Petr Lautrbach
  5 siblings, 0 replies; 8+ messages in thread
From: James Carter @ 2022-11-04 14:36 UTC (permalink / raw)
  To: selinux; +Cc: plautrba, James Carter

With the removal of any dependence on the python disutils module,
Debian no longer depends on the python3-disutils package.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/README.md b/README.md
index 74b0a0c3..f91cb7d9 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,6 @@ apt-get install --no-install-recommends --no-install-suggests \
     libpcre2-dev \
     pkgconf \
     python3 \
-    python3-distutils \
     systemd \
     xmlto
 
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/5 v3] Remove dependency on the Python module distutils
  2022-11-04 14:36 [PATCH 0/5 v3] Remove dependency on the Python module distutils James Carter
                   ` (4 preceding siblings ...)
  2022-11-04 14:36 ` [PATCH 5/5 v3] README.md: Remove mention of python3-distutils dependency James Carter
@ 2022-11-07  8:13 ` Petr Lautrbach
  2022-11-09 13:47   ` James Carter
  5 siblings, 1 reply; 8+ messages in thread
From: Petr Lautrbach @ 2022-11-07  8:13 UTC (permalink / raw)
  To: James Carter, selinux

James Carter <jwcart2@gmail.com> writes:

> 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

Acked-by: Petr Lautrbach <plautrba@redhat.com>


>  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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/5 v3] Remove dependency on the Python module distutils
  2022-11-07  8:13 ` [PATCH 0/5 v3] Remove dependency on the Python module distutils Petr Lautrbach
@ 2022-11-09 13:47   ` James Carter
  0 siblings, 0 replies; 8+ messages in thread
From: James Carter @ 2022-11-09 13:47 UTC (permalink / raw)
  To: Petr Lautrbach; +Cc: selinux

On Mon, Nov 7, 2022 at 3:14 AM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> James Carter <jwcart2@gmail.com> writes:
>
> > 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
>
> Acked-by: Petr Lautrbach <plautrba@redhat.com>
>

This series has been merged.
Jim

>
> >  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
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-09 13:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-04 14:36 [PATCH 0/5 v3] Remove dependency on the Python module distutils James Carter
2022-11-04 14:36 ` [PATCH 1/5 v3] libselinux: " James Carter
2022-11-04 14:36 ` [PATCH 2/5 v3] libsemanage: " James Carter
2022-11-04 14:36 ` [PATCH 3/5] python: " James Carter
2022-11-04 14:36 ` [PATCH 4/5 v3] scripts: " James Carter
2022-11-04 14:36 ` [PATCH 5/5 v3] README.md: Remove mention of python3-distutils dependency James Carter
2022-11-07  8:13 ` [PATCH 0/5 v3] Remove dependency on the Python module distutils Petr Lautrbach
2022-11-09 13:47   ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.