Skip to contentSkip to conversation

libselinux: update pywrap targets for modern python builds

PATCH Superseded Stephen Smalley 1 participant 2 messages May 15 SELinux security module

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH v2 1/2 libselinux: update pywrap targets for modern python builds

setup.py build is deprecated and no longer working on GitHub CI runners.

---
v2 finally passes the GitHub build tests for me in combination with the libsemanage tests fix.

 libselinux/src/.gitignore     |  1 +
 libselinux/src/Makefile       |  8 ++++----
 libselinux/src/pyproject.toml | 11 +++++++++++
 3 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 libselinux/src/pyproject.toml
libselinux/src/.gitignore +1 -0
index 94400e81..5413ccf0 100644
@@ -2,3 +2,4 @@ selinux.py
 selinuxswig_python_wrap.c
 selinuxswig_ruby_wrap.c
 selinux.egg-info/
+dist/
libselinux/src/Makefile +4 -4
index 6fce9fa5..c62ad1ed 100644
@@ -151,7 +151,8 @@ all: $(LIBSO)
 endif
 
 pywrap: all selinuxswig_python_exception.i
-	CFLAGS="$(CPPFLAGS) $(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext
+	$(PYTHON) -m pip install build wheel
+	CFLAGS="$(CPPFLAGS) $(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m build --no-isolation --wheel .
 
 rubywrap: all $(SWIGRUBYSO)
 
@@ -196,7 +197,7 @@ ifneq ($(DISABLE_SHARED),y)
 endif
 
 install-pywrap: pywrap
-	CFLAGS="$(CPPFLAGS) $(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --no-build-isolation --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
+	$(PYTHON) -m pip install --no-build-isolation --force-reinstall --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` dist/*.whl
 	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
 	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
 
@@ -209,8 +210,7 @@ relabel:
 
 clean-pywrap:
 	-rm -f $(SWIGLOBJ) $(SWIGSO) $(AUDIT2WHYLOBJ) $(AUDIT2WHYSO)
-	$(PYTHON) setup.py clean
-	-rm -rf build *~ \#* *pyc .#* selinux.egg-info/
+	-rm -rf build dist *.egg-info *~ \#* *pyc .#*
 
 clean-rubywrap:
 	-rm -f $(SWIGRUBYLOBJ) $(SWIGRUBYSO)
libselinux/src/pyproject.toml new file +11 -0
new file mode 100644
index 00000000..74dbbc34
@@ -0,0 +1,11 @@
+[build-system]
+requires = ["setuptools", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "selinux"
+version = "3.10"
+description = "SELinux python 3 bindings"
+authors = [
+  { name = "SELinux Project", email = "[email protected]" }
+]
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH v2 2/2 python/sepolicy: update for modern python builds

setup.py build is deprecated and no longer working on GitHub CI runners.

---
 python/sepolicy/.gitignore     |  1 +
 python/sepolicy/Makefile       | 10 +++++-----
 python/sepolicy/pyproject.toml | 23 +++++++++++++++++++++++
 3 files changed, 29 insertions(+), 5 deletions(-)
 create mode 100644 python/sepolicy/pyproject.toml
python/sepolicy/.gitignore +1 -0
index 32fb47f9..80824997 100644
@@ -2,3 +2,4 @@ build
 tmp
 *.bak
 sepolicy.egg-info/
+dist/
python/sepolicy/Makefile +5 -5
index ccb22fe7..4a4a3512 100644
@@ -14,11 +14,11 @@ BASHCOMPLETIONS=sepolicy-bash-completion.sh
 all: python-build
 
 python-build:
-	$(PYTHON) setup.py build
+	$(PYTHON) -m pip install build wheel setuptools
+	$(PYTHON) -m build --no-isolation --wheel .
 
 clean:
-	$(PYTHON) setup.py clean
-	-rm -rf build *~ \#* *pyc .#* sepolicy.egg-info/
+	-rm -rf build dist *.egg-info *~ \#* *pyc .#*
 
 sepolgen:
 	ln -sf sepolicy sepolgen
@@ -26,8 +26,8 @@ sepolgen:
 test:
 	@$(PYTHON) test_sepolicy.py -v
 
-install:
-	$(PYTHON) -m pip install --no-build-isolation --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
+install: python-build
+	$(PYTHON) -m pip install --no-build-isolation --force-reinstall --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` dist/*.whl
 	[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
 	install -m 755 sepolicy.py $(DESTDIR)$(BINDIR)/sepolicy
 	(cd $(DESTDIR)$(BINDIR); ln -sf sepolicy sepolgen)
python/sepolicy/pyproject.toml new file +23 -0
new file mode 100644
index 00000000..dc72bc8e
@@ -0,0 +1,23 @@
+[build-system]
+requires = ["setuptools", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "sepolicy"
+version = "3.10"
+description = "SELinux Policy python bindings"
+authors = [
+  { name = "SELinux Project", email = "[email protected]" }
+]
+
+[project.scripts]
+sepolicy = "sepolicy:main"
+sepolgen = "sepolicy:main"
+
+[tool.setuptools]
+packages = ["sepolicy", "sepolicy.templates", "sepolicy.help"]
+
+[tool.setuptools.package-data]
+sepolicy = ["*.glade"]
+"sepolicy.help" = ["*.txt", "*.png"]
+
Signature · 1 line
2.54.0