Skip to contentSkip to conversation

Use `pip install` instead of `setup.py install`

PATCH In review Petr Lautrbach 2 participants 2 messages Nov 29, 2022 – Dec 16, 2022 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Use `pip install` instead of `setup.py install`

Fixes:
/usr/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

---
 README.md                | 8 +++++++-
 libselinux/src/Makefile  | 2 +-
 python/sepolicy/Makefile | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)
README.md +7 -1
index 529b7e46c871..c272ce89fec5 100644
@@ -62,6 +62,9 @@ dnf install \
 # For Python and Ruby bindings
 dnf install \
     python3-devel \
+    python3-pip \
+    python3-setuptools \
+    python3-wheel \
     ruby-devel \
     swig
 ```
@@ -92,6 +95,9 @@ apt-get install --no-install-recommends --no-install-suggests \
 # For Python and Ruby bindings
 apt-get install --no-install-recommends --no-install-suggests \
     python3-dev \
+    python3-pip \
+    python3-setuptools \
+    python3-wheel \
     ruby-dev \
     swig
 ```
@@ -102,7 +108,7 @@ To build and install everything under a private directory, run:
 
     make DESTDIR=~/obj install install-rubywrap install-pywrap
 
-On Debian `PYTHON_SETUP_ARGS=--install-layout=deb` needs to be set when installing the python wrappers in order to create the correct python directory structure.
+On Debian `PYTHON_SETUP_ARGS='--install-option "--install-layout=deb"'` needs to be set when installing the python wrappers in order to create the correct python directory structure.
 
 To run tests with the built libraries and programs, several paths (relative to `$DESTDIR`) need to be added to variables `$LD_LIBRARY_PATH`, `$PATH` and `$PYTHONPATH`.
 This can be done using [./scripts/env_use_destdir](./scripts/env_use_destdir):
libselinux/src/Makefile +1 -1
index dc2848322e4d..0f6396ababa4 100644
@@ -187,7 +187,7 @@ install: all
 	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
 
 install-pywrap: pywrap
-	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS)
+	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS) .
 	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
 	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
 
python/sepolicy/Makefile +1 -1
index d983e409e5e6..57a2e55edbbf 100644
@@ -27,7 +27,7 @@ test:
 	@$(PYTHON) test_sepolicy.py -v
 
 install:
-	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS)
+	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS) .
 	[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
 	install -m 755 sepolicy.py $(DESTDIR)$(BINDIR)/sepolicy
 	(cd $(DESTDIR)$(BINDIR); ln -sf sepolicy sepolgen)
Signature · 1 line
2.38.1
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Petr Lautrbach

Fixes:
/usr/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

I made a mess of this. I merged the earlier patch by mistake, that has been reverted and this version merged.

and merged.

Thanks,
Jim

Quoted 68 lines
---
 README.md                | 8 +++++++-
 libselinux/src/Makefile  | 2 +-
 python/sepolicy/Makefile | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)
README.md +7 -1
index 529b7e46c871..c272ce89fec5 100644
@@ -62,6 +62,9 @@ dnf install \
 # For Python and Ruby bindings
 dnf install \
     python3-devel \
+    python3-pip \
+    python3-setuptools \
+    python3-wheel \
     ruby-devel \
     swig
 ```
@@ -92,6 +95,9 @@ apt-get install --no-install-recommends --no-install-suggests \
 # For Python and Ruby bindings
 apt-get install --no-install-recommends --no-install-suggests \
     python3-dev \
+    python3-pip \
+    python3-setuptools \
+    python3-wheel \
     ruby-dev \
     swig
 ```
@@ -102,7 +108,7 @@ To build and install everything under a private directory, run:
 
     make DESTDIR=~/obj install install-rubywrap install-pywrap
 
-On Debian `PYTHON_SETUP_ARGS=--install-layout=deb` needs to be set when installing the python wrappers in order to create the correct python directory structure.
+On Debian `PYTHON_SETUP_ARGS='--install-option "--install-layout=deb"'` needs to be set when installing the python wrappers in order to create the correct python directory structure.
 
 To run tests with the built libraries and programs, several paths (relative to `$DESTDIR`) need to be added to variables `$LD_LIBRARY_PATH`, `$PATH` and `$PYTHONPATH`.
 This can be done using [./scripts/env_use_destdir](./scripts/env_use_destdir):
libselinux/src/Makefile +1 -1
index dc2848322e4d..0f6396ababa4 100644
@@ -187,7 +187,7 @@ install: all
        ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
 
 install-pywrap: pywrap
-       $(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS)
+       $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS) .
        install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
        ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
 
python/sepolicy/Makefile +1 -2
index d983e409e5e6..57a2e55edbbf 100644
@@ -27,7 +27,7 @@ test:
        @$(PYTHON) test_sepolicy.py -v
 
 install:
-       $(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS)
+       $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS) .
        [ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
        install -m 755 sepolicy.py $(DESTDIR)$(BINDIR)/sepolicy
        (cd $(DESTDIR)$(BINDIR); ln -sf sepolicy sepolgen)
--

2.38.1