tree-wide: install python libraries on Debian with appropriate option
PATCH 1/1 tree-wide: install python libraries on Debian with appropriate option
On Debian the distutils module is patched, so get_python_lib() returns by default /usr/lib/python3/dist-packages (no minor version).
But setuptools affecting setup.py is not patched to create the library directory at /usr/lib/python3/dist-packages by default, rather than a command line argument --install-layout deb is added.
Add this option to python setup.py install invocation on Debian.
See https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html section B.1.
--- libselinux/src/Makefile | 2 +- python/sepolicy/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
libselinux/src/Makefile +1 -1
@@ -173,7 +173,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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` `grep -qxF ID=debian /etc/os-release && echo --install-layout deb` 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
@@ -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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` `grep -qxF ID=debian /etc/os-release && echo --install-layout deb` [ -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.26.0
Quoted 21 lines · Christian Göttsche
On Debian the
distutilsmodule is patched, soget_python_lib()returns by default/usr/lib/python3/dist-packages(no minor version).But
setuptoolsaffectingsetup.pyis not patched to create the library directory at/usr/lib/python3/dist-packagesby default, rather than a command line argument--install-layout debis added.Add this option to
python setup.py installinvocation on Debian.See https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html section B.1.
Signed-off-by Christian Göttsche <[email protected]>--- libselinux/src/Makefile | 2 +- python/sepolicy/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)libselinux/src/Makefile +0
-0
libselinux/src/Makefile install: all · line 176
Quoted 5 lines
libselinux/src/Makefile +1
-1@@ -173,7 +173,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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` `grep -qxF ID=debian /etc/os-release && echo --install-layout deb`
Wouldn't it be cleaner to instead add something like $(PYTHON_SETUP_ARGS) and build with 'make PYTHON_SETUP_ARGS=--install-layout=deb ...' on Debian?
Quoted 17 lines
libselinux/src/Makefile +0
-0install -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@@ -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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` `grep -qxF ID=debian /etc/os-release && echo --install-layout deb` [ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) install -m 755 sepolicy.py $(DESTDIR)$(BINDIR)/sepolicy (cd $(DESTDIR)$(BINDIR); ln -sf sepolicy sepolgen) --
Quoted 2 lines
2.26.0
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
PATCH v2 1/1 tree-wide: introduce PYTON_SETUP_ARGS to customize setup.py calls on Debian
In reply to Christian GöttscheOn Debian the distutils module is patched, so get_python_lib() returns by default /usr/lib/python3/dist-packages (no minor version).
But setuptools affecting setup.py is not patched to create the library directory at /usr/lib/python3/dist-packages by default, rather than a command line argument --install-layout deb is added.
Add PYTON_SETUP_ARGS as argument to affected setup.py calls and add a note in the global ReadMe.
See https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html section B.1.
---
v2:
Use env variable PYTON_SETUP_ARGS instead of internal detection logic
README.md | 2 ++ libselinux/src/Makefile | 2 +- python/sepolicy/Makefile | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
README.md +2 -0
@@ -18,6 +18,8 @@ To build and install everything under a private directory, run: make DESTDIR=~/obj install install-pywrap +Note: On Debian `PYTON_SETUP_ARGS=--install-layout=deb` needs to be set in order to create the correct python directory structure. + To install as the default system libraries and binaries (overwriting any previously installed ones - dangerous!), on x86_64, run:
libselinux/src/Makefile +1 -1
@@ -174,7 +174,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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTON_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
@@ -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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTON_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.26.2
Re: [PATCH v2] tree-wide: introduce PYTON_SETUP_ARGS to customize setup.py calls on Debian
Quoted 2 lines · Christian Göttsche
On Debian the
distutilsmodule is patched, soget_python_lib()returns by default/usr/lib/python3/dist-packages(no minor version).
Could you wrap the commit message to 75 chars per line, please?
Quoted 3 lines
But
setuptoolsaffectingsetup.pyis not patched to create the library directory at/usr/lib/python3/dist-packagesby default, rather than a command line argument--install-layout debis added.Add
PYTON_SETUP_ARGSas argument to affectedsetup.pycalls and add a note in the global ReadMe.
Fix the file name - ReadMe -> README.md
Quoted 4 lines
See https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html section B.1.
Please provide Signed-off-by:
Also there's a conflicting patch which changes README.md as well -
https://patchwork.kernel.org/patch/11522349/ which I'm going to merge. Could you please rebase this patch based on changes from the mentioned patch?
Other than the comments above, I like the patch. Thanks!
Quoted 51 lines
---
v2:
Use env variablePYTON_SETUP_ARGSinstead of internal detection logicREADME.md | 2 ++ libselinux/src/Makefile | 2 +- python/sepolicy/Makefile | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)README.md +2
-0@@ -18,6 +18,8 @@ To build and install everything under a private directory, run: make DESTDIR=~/obj install install-pywrap +Note: On Debian `PYTON_SETUP_ARGS=--install-layout=deb` needs to be set in order to create the correct python directory structure. + To install as the default system libraries and binaries (overwriting any previously installed ones - dangerous!), on x86_64, run:libselinux/src/Makefile +1
-1@@ -174,7 +174,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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTON_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@@ -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.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTON_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.26.2
Re: [PATCH v2] tree-wide: introduce PYTON_SETUP_ARGS to customize setup.py calls on Debian
Quoted 17 lines · Petr Lautrbach
Quoted 2 lines · Christian Göttsche
On Debian the
distutilsmodule is patched, soget_python_lib()returns by default/usr/lib/python3/dist-packages(no minor version).Could you wrap the commit message to 75 chars per line, please?
Quoted 3 lines
But
setuptoolsaffectingsetup.pyis not patched to create the library directory at/usr/lib/python3/dist-packagesby default, rather than a command line argument--install-layout debis added.Add
PYTON_SETUP_ARGSas argument to affectedsetup.pycalls and add a note in the global ReadMe.Fix the file name - ReadMe -> README.md
Quoted 4 lines
See https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html section B.1.
Quoted 7 lines
Please provide Signed-off-by:
Also there's a conflicting patch which changes README.md as well -
https://patchwork.kernel.org/patch/11522349/ which I'm going to merge. Could you please rebase this patch based on changes from the mentioned patch?Other than the comments above, I like the patch. Thanks!
Also, please fix the typo: s/PYTON/PYTHON/g (both in the commit message and code/README). I only spotted it now after reading Petr's reply :)
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.
PATCH v3 1/1 tree-wide: introduce PYTHON_SETUP_ARGS to customize setup.py calls on Debian
In reply to Christian GöttscheOn Debian the distutils module is patched, so get_python_lib() returns by default /usr/lib/python3/dist-packages (no minor version)
But setuptools affecting setup.py is not patched to create the library directory at /usr/lib/python3/dist-packages by default, rather than a command line argument --install-layout deb is added
Add PYTHON_SETUP_ARGS as argument to affected setup.py calls and add a note in the global README.md
See https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html
Section B.1
---
v3:
- Correctly spell python
- wrap commit message
v2:
Use env variable PYTON_SETUP_ARGS instead of internal detection logic
README.md | 2 ++ libselinux/src/Makefile | 2 +- python/sepolicy/Makefile | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
README.md +2 -0
@@ -95,6 +95,8 @@ 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. + 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
@@ -174,7 +174,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.py 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
@@ -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.py 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.26.2
Re: [PATCH v3] tree-wide: introduce PYTHON_SETUP_ARGS to customize setup.py calls on Debian
Quoted 10 lines · Christian Göttsche
On Debian the
distutilsmodule is patched, soget_python_lib()returns by default/usr/lib/python3/dist-packages(no minor version)But
setuptoolsaffectingsetup.pyis not patched to create the library directory at/usr/lib/python3/dist-packagesby default, rather than a command line argument--install-layout debis addedAdd
PYTHON_SETUP_ARGSas argument to affectedsetup.pycalls and add a note in the global README.md
Quoted 6 lines
See https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html
Section B.1Signed-off-by Christian Göttsche <[email protected]>
Thanks!
Quoted 55 lines
---
v3:
- Correctly spell python
- wrap commit messagev2:
Use env variablePYTON_SETUP_ARGSinstead of internal detection logicREADME.md | 2 ++ libselinux/src/Makefile | 2 +- python/sepolicy/Makefile | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)README.md +2
-0@@ -95,6 +95,8 @@ 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. + 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@@ -174,7 +174,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.py 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@@ -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.py 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.26.2
Signature · 2 lines
() ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments
Petr Lautrbach
AppliedRe: [PATCH v3] tree-wide: introduce PYTHON_SETUP_ARGS to customize setup.py calls on Debian
Quoted 14 lines · Petr Lautrbach
Quoted 13 lines · Christian Göttsche
On Debian the
distutilsmodule is patched, soget_python_lib()returns by default/usr/lib/python3/dist-packages(no minor version)But
setuptoolsaffectingsetup.pyis not patched to create the library directory at/usr/lib/python3/dist-packagesby default, rather than a command line argument--install-layout debis addedAdd
PYTHON_SETUP_ARGSas argument to affectedsetup.pycalls and add a note in the global README.mdSee https://www.debian.org/doc/packaging-manuals/python-policy/packaging_tools.html
Section B.1
Quoted 7 lines
Quoted 3 lines
Signed-off-by Christian Göttsche <[email protected]>Acked-by Petr Lautrbach <[email protected]>Thanks!
Applied.
Quoted 60 lines
Quoted 56 lines
---
v3:
- Correctly spell python
- wrap commit messagev2:
Use env variablePYTON_SETUP_ARGSinstead of internal detection logicREADME.md | 2 ++ libselinux/src/Makefile | 2 +- python/sepolicy/Makefile | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)README.md +2
-0@@ -95,6 +95,8 @@ 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. + 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@@ -174,7 +174,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.py 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@@ -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.py 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.26.2Signature · 2 lines
() ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments
Signature · 2 lines
() ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments