commit:     6f81dc7ef7f9e427243a4c21d40a0fdc9bb4d681
Author:     Kenton Groombridge <concord <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  7 15:32:38 2025 +0000
Commit:     Kenton Groombridge <concord <AT> gentoo <DOT> org>
CommitDate: Mon Nov 17 22:14:03 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6f81dc7e

sys-libs/libselinux: use distutils-r1 for python module

pip 25.3 drops code paths for non-PEP 517 which, as a
side effect, breaks the Python module build in
libselinux. Fix this properly by using distutils-r1.

Closes: https://bugs.gentoo.org/965451
Signed-off-by: Kenton Groombridge <concord <AT> gentoo.org>

 ...nux-3.8.1.ebuild => libselinux-3.8.1-r1.ebuild} | 61 ++++++++++++----------
 sys-libs/libselinux/libselinux-9999.ebuild         | 61 ++++++++++++----------
 2 files changed, 66 insertions(+), 56 deletions(-)

diff --git a/sys-libs/libselinux/libselinux-3.8.1.ebuild 
b/sys-libs/libselinux/libselinux-3.8.1-r1.ebuild
similarity index 81%
rename from sys-libs/libselinux/libselinux-3.8.1.ebuild
rename to sys-libs/libselinux/libselinux-3.8.1-r1.ebuild
index a940e1af6f76..3d2d95404922 100644
--- a/sys-libs/libselinux/libselinux-3.8.1.ebuild
+++ b/sys-libs/libselinux/libselinux-3.8.1-r1.ebuild
@@ -3,11 +3,13 @@
 
 EAPI=8
 
+DISTUTILS_USE_PEP517=setuptools
+DISTUTILS_EXT=1
 PYTHON_COMPAT=( python3_{11..14} )
 USE_RUBY="ruby32 ruby33"
 
 # No, I am not calling ruby-ng
-inherit python-r1 toolchain-funcs multilib-minimal
+inherit distutils-r1 toolchain-funcs multilib-minimal
 
 MY_PV="${PV//_/-}"
 MY_P="${PN}-${MY_PV}"
@@ -66,20 +68,6 @@ multilib_src_compile() {
                FTS_LDLIBS="$(usex elibc_musl '-lfts' '')" \
                all
 
-       if multilib_is_native_abi && use python; then
-               building() {
-                       emake \
-                               LDFLAGS="-fPIC ${LDFLAGS} -lpthread" \
-                               LIBDIR="\$(PREFIX)/$(get_libdir)" \
-                               SHLIBDIR="/$(get_libdir)" \
-                               USE_PCRE2=y \
-                               USE_LFS=y \
-                               FTS_LDLIBS="$(usex elibc_musl '-lfts' '')" \
-                               pywrap
-               }
-               python_foreach_impl building
-       fi
-
        if multilib_is_native_abi && use ruby; then
                building() {
                        einfo "Calling rubywrap for ${1}"
@@ -103,6 +91,15 @@ multilib_src_compile() {
        fi
 }
 
+src_compile() {
+       multilib-minimal_src_compile
+
+       if use python; then
+               cd src || die
+               distutils-r1_src_compile
+       fi
+}
+
 multilib_src_install() {
        emake DESTDIR="${D}" \
                LIBDIR="\$(PREFIX)/$(get_libdir)" \
@@ -111,19 +108,6 @@ multilib_src_install() {
                USE_PCRE2=y \
                install
 
-       if multilib_is_native_abi && use python; then
-               installation() {
-                       emake DESTDIR="${D}" \
-                               LIBDIR="\$(PREFIX)/$(get_libdir)" \
-                               SHLIBDIR="/$(get_libdir)" \
-                               USE_LFS=y \
-                               USE_PCRE2=y \
-                               install-pywrap
-                       python_optimize # bug 531638
-               }
-               python_foreach_impl installation
-       fi
-
        if multilib_is_native_abi && use ruby; then
                installation() {
                        einfo "Calling install-rubywrap for ${1}"
@@ -147,6 +131,27 @@ multilib_src_install() {
        use static-libs || rm "${ED}"/usr/$(get_libdir)/*.a || die
 }
 
+multilib_src_install_all() {
+       if use python; then
+               cd src || die
+               mv selinux.py __init__.py || die
+               distutils-r1_src_install
+       fi
+}
+
+python_install() {
+       # this installs the C extensions only
+       distutils-r1_python_install
+
+       # now explicitly install the python package
+       python_moduleinto selinux
+       python_domodule __init__.py
+
+       # install the C extension symlink
+       local pycext="$(python -c 'import 
importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES[0])' || die)"
+       dosym -r "$(python_get_sitedir)/selinux/_selinux${pycext}" 
"$(python_get_sitedir)/_selinux${pycext}"
+}
+
 pkg_postinst() {
        # Fix bug 473502
        for POLTYPE in ${POLICY_TYPES};

diff --git a/sys-libs/libselinux/libselinux-9999.ebuild 
b/sys-libs/libselinux/libselinux-9999.ebuild
index da394c50dfda..cb6d3ab5c7b7 100644
--- a/sys-libs/libselinux/libselinux-9999.ebuild
+++ b/sys-libs/libselinux/libselinux-9999.ebuild
@@ -3,11 +3,13 @@
 
 EAPI=8
 
+DISTUTILS_USE_PEP517=setuptools
+DISTUTILS_EXT=1
 PYTHON_COMPAT=( python3_{11..14} )
 USE_RUBY="ruby32 ruby33"
 
 # No, I am not calling ruby-ng
-inherit python-r1 toolchain-funcs multilib-minimal
+inherit distutils-r1 toolchain-funcs multilib-minimal
 
 MY_PV="${PV//_/-}"
 MY_P="${PN}-${MY_PV}"
@@ -66,20 +68,6 @@ multilib_src_compile() {
                FTS_LDLIBS="$(usex elibc_musl '-lfts' '')" \
                all
 
-       if multilib_is_native_abi && use python; then
-               building() {
-                       emake \
-                               LDFLAGS="-fPIC ${LDFLAGS} -lpthread" \
-                               LIBDIR="\$(PREFIX)/$(get_libdir)" \
-                               SHLIBDIR="/$(get_libdir)" \
-                               USE_PCRE2=y \
-                               USE_LFS=y \
-                               FTS_LDLIBS="$(usex elibc_musl '-lfts' '')" \
-                               pywrap
-               }
-               python_foreach_impl building
-       fi
-
        if multilib_is_native_abi && use ruby; then
                building() {
                        einfo "Calling rubywrap for ${1}"
@@ -103,6 +91,15 @@ multilib_src_compile() {
        fi
 }
 
+src_compile() {
+       multilib-minimal_src_compile
+
+       if use python; then
+               cd src || die
+               distutils-r1_src_compile
+       fi
+}
+
 multilib_src_install() {
        emake DESTDIR="${D}" \
                LIBDIR="\$(PREFIX)/$(get_libdir)" \
@@ -111,19 +108,6 @@ multilib_src_install() {
                USE_PCRE2=y \
                install
 
-       if multilib_is_native_abi && use python; then
-               installation() {
-                       emake DESTDIR="${D}" \
-                               LIBDIR="\$(PREFIX)/$(get_libdir)" \
-                               SHLIBDIR="/$(get_libdir)" \
-                               USE_LFS=y \
-                               USE_PCRE2=y \
-                               install-pywrap
-                       python_optimize # bug 531638
-               }
-               python_foreach_impl installation
-       fi
-
        if multilib_is_native_abi && use ruby; then
                installation() {
                        einfo "Calling install-rubywrap for ${1}"
@@ -147,6 +131,27 @@ multilib_src_install() {
        use static-libs || rm "${ED}"/usr/$(get_libdir)/*.a || die
 }
 
+multilib_src_install_all() {
+       if use python; then
+               cd src || die
+               mv selinux.py __init__.py || die
+               distutils-r1_src_install
+       fi
+}
+
+python_install() {
+       # this installs the C extensions only
+       distutils-r1_python_install
+
+       # now explicitly install the python package
+       python_moduleinto selinux
+       python_domodule __init__.py
+
+       # install the C extension symlink
+       local pycext="$(python -c 'import 
importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES[0])' || die)"
+       dosym -r "$(python_get_sitedir)/selinux/_selinux${pycext}" 
"$(python_get_sitedir)/_selinux${pycext}"
+}
+
 pkg_postinst() {
        # Fix bug 473502
        for POLTYPE in ${POLICY_TYPES};

Reply via email to