Skip to contentSkip to conversation

package/libselinux: fix python bindings with pip 25.3

PATCH Applied Thomas Perale via buildroot 1 participant 2 messages Oct 31 – Nov 6

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libselinux: fix python bindings with pip 25.3

Since the pip bump to 25.3 on 2025.02.x [1], the build of the Python bindings of libselinux is broken for both the host and target variants.

This can be reproduced with the following defconfig:

```
BR2_aarch64=y
BR2_cortex_a72=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_LIBSELINUX=y
```

This has already been fixed on the master branch with Buildroot commit [2].
At the time this commit has been cherry-picked on 2025.02.x [3] and later reverted has pip version 25.3 was not present at the time on 2025.02.x [4].

This commit cherrypick and backport again the fix present on master to fix libselinux build.

[1] 6615c3ad30 package/python-pip: bumpp version to 25.3
[2] 0e5eef911c package/libselinux: allow pip to use system-provided packages
[3] 32d1d7c367104d23cc9eec2762a7e543afdafd9e
[4] ae7e57a9622474534f5e67af7750c1b0ccb9ff4f

Fixes 6615c3ad30 package/python-pip: bumpp version to 25.3

(alternative to commit 0e5eef911c9b313fddd9912128bf09d605b5f6ae)

---
 ...akefile-build-python-module-without-.patch | 52 +++++++++++++++++++
 package/libselinux/libselinux.mk              |  4 ++
 2 files changed, 56 insertions(+)
 create mode 100644 package/libselinux/0003-libselinux-src-Makefile-build-python-module-without-.patch
package/libselinux/0003-libselinux-src-Makefile-build-python-module-without-.patch new file +52 -0
new file mode 100644
index 0000000000..9ca87f0b49
@@ -0,0 +1,52 @@
+From 17a9372391ad2c9bf0e440391d6fd13cb8cfdaf3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <[email protected]>
+Date: Sat, 27 Dec 2025 15:39:11 +0100
+Subject: [PATCH] libselinux/src/Makefile: build python module without
+ isolation
+
+The "pip install" logic in libselinux/src/Makefile tries to get
+setuptools from the network, which is not correct as during the
+build/installation, there shouldn't be any network access, or
+downloading of arbitrary resources from the network.
+
+This causes build issues in Debian:
+
+  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1121121
+
+And in Buildroot:
+
+  https://autobuild.buildroot.net/results/0e9/0e9de0c0d8b6ec57eea9f8834f02076b296ba4f1/build-end.log
+
+To fix this, we use the --no-build-isolation pip install argument so
+that pip install is allowed to use the system-provided setuptools,
+instead of wanting to download this one.
+
+This patch is derived from
+https://sources.debian.org/src/libselinux/3.9-4/debian/patches/Build-python-module-without-isolation-Closes-1119155.patch,
+with the change that --no-build-isolation is passed unconditionally,
+regardless of whether $(DESTDIR) is empty or not.
+
+Acked-by: James Carter <[email protected]>
+Signed-off-by: Bernd Kuhls <[email protected]>
+Signed-off-by: Thomas Petazzoni <[email protected]>
+Upstream: https://github.com/SELinuxProject/selinux/commit/17a9372391ad2c9bf0e440391d6fd13cb8cfdaf3
+---
+ src/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Makefile b/src/Makefile
+index e9141bb9..9bc10606 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -190,7 +190,7 @@
+ 	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
+ 
+ install-pywrap: pywrap
+-	CFLAGS="$(CPPFLAGS) $(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
++	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) .
+ 	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
+ 	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux*.so $(DESTDIR)$(PYTHONLIBDIR)/
+ 
+-- 
+2.52.0
+
package/libselinux/libselinux.mk +4 -0
index 360ab063ca..7bc33392d5 100644
@@ -35,8 +35,12 @@ LIBSELINUX_DEPENDENCIES += \
 	python3 \
 	python-setuptools \
 	host-python-pip \
+	host-python-setuptools \
 	host-swig
 
+LIBSELINUX_MAKE_ENV += \
+	$(PKG_PYTHON_SETUPTOOLS_ENV)
+
 LIBSELINUX_MAKE_OPTS += \
 	$(PKG_PYTHON_SETUPTOOLS_ENV) \
 	PYTHON=python$(PYTHON3_VERSION_MAJOR)
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

In reply of:

Quoted 28 lines

Since the pip bump to 25.3 on 2025.02.x [1], the build of the Python bindings of libselinux is broken for both the host and target variants.

This can be reproduced with the following defconfig:

```
BR2_aarch64=y
BR2_cortex_a72=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_LIBSELINUX=y
```

This has already been fixed on the master branch with Buildroot commit [2].
At the time this commit has been cherry-picked on 2025.02.x [3] and later reverted has pip version 25.3 was not present at the time on 2025.02.x [4].

This commit cherrypick and backport again the fix present on master to fix libselinux build.

[1] 6615c3ad30 package/python-pip: bumpp version to 25.3
[2] 0e5eef911c package/libselinux: allow pip to use system-provided packages
[3] 32d1d7c367104d23cc9eec2762a7e543afdafd9e
[4] ae7e57a9622474534f5e67af7750c1b0ccb9ff4f

Quoted 4 lines
Fixes 6615c3ad30 package/python-pip: bumpp version to 25.3

(alternative to commit 0e5eef911c9b313fddd9912128bf09d605b5f6ae)

Applied to 2025.02.x. Thanks

Quoted 71 lines
---
 ...akefile-build-python-module-without-.patch | 52 +++++++++++++++++++
 package/libselinux/libselinux.mk              |  4 ++
 2 files changed, 56 insertions(+)
 create mode 100644 package/libselinux/0003-libselinux-src-Makefile-build-python-module-without-.patch
package/libselinux/0003-libselinux-src-Makefile-build-python-module-without-.patch new file +52 -0
new file mode 100644
index 0000000000..9ca87f0b49
@@ -0,0 +1,52 @@
+From 17a9372391ad2c9bf0e440391d6fd13cb8cfdaf3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <[email protected]>
+Date: Sat, 27 Dec 2025 15:39:11 +0100
+Subject: [PATCH] libselinux/src/Makefile: build python module without
+ isolation
+
+The "pip install" logic in libselinux/src/Makefile tries to get
+setuptools from the network, which is not correct as during the
+build/installation, there shouldn't be any network access, or
+downloading of arbitrary resources from the network.
+
+This causes build issues in Debian:
+
+  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1121121
+
+And in Buildroot:
+
+  https://autobuild.buildroot.net/results/0e9/0e9de0c0d8b6ec57eea9f8834f02076b296ba4f1/build-end.log
+
+To fix this, we use the --no-build-isolation pip install argument so
+that pip install is allowed to use the system-provided setuptools,
+instead of wanting to download this one.
+
+This patch is derived from
+https://sources.debian.org/src/libselinux/3.9-4/debian/patches/Build-python-module-without-isolation-Closes-1119155.patch,
+with the change that --no-build-isolation is passed unconditionally,
+regardless of whether $(DESTDIR) is empty or not.
+
+Acked-by: James Carter <[email protected]>
+Signed-off-by: Bernd Kuhls <[email protected]>
+Signed-off-by: Thomas Petazzoni <[email protected]>
+Upstream: https://github.com/SELinuxProject/selinux/commit/17a9372391ad2c9bf0e440391d6fd13cb8cfdaf3
+---
+ src/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Makefile b/src/Makefile
+index e9141bb9..9bc10606 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -190,7 +190,7 @@
+ 	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
+ 
+ install-pywrap: pywrap
+-	CFLAGS="$(CPPFLAGS) $(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
++	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) .
+ 	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
+ 	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux*.so $(DESTDIR)$(PYTHONLIBDIR)/
+ 
+-- 
+2.52.0
+
package/libselinux/libselinux.mk +0 -0
index 360ab063ca..7bc33392d5 100644
@@ -35,8 +35,12 @@ LIBSELINUX_DEPENDENCIES += \
 	python3 \
 	python-setuptools \

package/libselinux/libselinux.mk LIBSELINUX_DEPENDENCIES += \ · line 46

Quoted 10 lines
package/libselinux/libselinux.mk +4 -0
 	host-python-pip \
+	host-python-setuptools \
 	host-swig
 
+LIBSELINUX_MAKE_ENV += \
+	$(PKG_PYTHON_SETUPTOOLS_ENV)
+
 LIBSELINUX_MAKE_OPTS += \
 	$(PKG_PYTHON_SETUPTOOLS_ENV) \
 	PYTHON=python$(PYTHON3_VERSION_MAJOR)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot