commit:     35682fb9cc368eedd2568009b1b6a2ad81c997be
Author:     Krzesimir Nowak <knowak <AT> microsoft <DOT> com>
AuthorDate: Tue Feb 17 14:29:23 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 10:00:21 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=35682fb9

sys-libs/libselinux: Make python dependency optional

Typically, the distutils-r1.eclass pulls in dev-lang/python
unconditionally unless we set DISTUTILS_OPTIONAL variable to non-null
value. Let's do that, since the package already has a python USE flag
for gating the python dependency.

Specifying DISTUTILS_OPTIONAL requires manually invoking distutils
eclass' phase functions. So let's make sure that they are invoked only
if USE=python is enabled.

Signed-off-by: Krzesimir Nowak <knowak <AT> microsoft.com>
Part-of: https://codeberg.org/gentoo/gentoo/pulls/87
Merges: https://codeberg.org/gentoo/gentoo/pulls/87
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...inux-9999.ebuild => libselinux-3.8.1-r3.ebuild} | 29 ++++++++++++++++++++--
 sys-libs/libselinux/libselinux-9999.ebuild         | 27 ++++++++++++++++++--
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/sys-libs/libselinux/libselinux-9999.ebuild 
b/sys-libs/libselinux/libselinux-3.8.1-r3.ebuild
similarity index 91%
copy from sys-libs/libselinux/libselinux-9999.ebuild
copy to sys-libs/libselinux/libselinux-3.8.1-r3.ebuild
index 372ceec423d8..37186db206aa 100644
--- a/sys-libs/libselinux/libselinux-9999.ebuild
+++ b/sys-libs/libselinux/libselinux-3.8.1-r3.ebuild
@@ -1,10 +1,11 @@
-# Copyright 1999-2025 Gentoo Authors
+# Copyright 1999-2026 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
 DISTUTILS_EXT=1
+DISTUTILS_OPTIONAL=1
 PYTHON_COMPAT=( python3_{11..14} )
 USE_RUBY="ruby32 ruby33"
 
@@ -45,15 +46,30 @@ BDEPEND="virtual/pkgconfig
        python? (
                >=dev-lang/swig-2.0.9
                dev-python/pip[${PYTHON_USEDEP}]
-)
+               ${PYTHON_DEPS}
+               ${DISTUTILS_DEPS}
+       )
        ruby? ( >=dev-lang/swig-2.0.9 )"
 
 src_prepare() {
        eapply_user
 
+       if use python; then
+               distutils-r1_src_prepare
+       fi
+
        multilib_copy_sources
 }
 
+multilib_src_configure() {
+       default
+       if multilib_is_native_abi; then
+               if use python; then
+                       distutils-r1_src_configure
+               fi
+       fi
+}
+
 multilib_src_compile() {
        tc-export AR CC PKG_CONFIG RANLIB
 
@@ -150,6 +166,15 @@ python_install() {
        dosym -r "$(python_get_sitedir)/selinux/_selinux${pycext}" 
"$(python_get_sitedir)/_selinux${pycext}"
 }
 
+multilib_src_test() {
+       default
+       if multilib_is_native_abi; then
+               if use python; then
+                       distutils-r1_src_test
+               fi
+       fi
+}
+
 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 372ceec423d8..cc8d0992621b 100644
--- a/sys-libs/libselinux/libselinux-9999.ebuild
+++ b/sys-libs/libselinux/libselinux-9999.ebuild
@@ -1,10 +1,11 @@
-# Copyright 1999-2025 Gentoo Authors
+# Copyright 1999-2026 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
 DISTUTILS_EXT=1
+DISTUTILS_OPTIONAL=1
 PYTHON_COMPAT=( python3_{11..14} )
 USE_RUBY="ruby32 ruby33"
 
@@ -45,15 +46,30 @@ BDEPEND="virtual/pkgconfig
        python? (
                >=dev-lang/swig-2.0.9
                dev-python/pip[${PYTHON_USEDEP}]
-)
+               ${PYTHON_DEPS}
+               ${DISTUTILS_DEPS}
+       )
        ruby? ( >=dev-lang/swig-2.0.9 )"
 
 src_prepare() {
        eapply_user
 
+       if use python; then
+               distutils-r1_src_prepare
+       fi
+
        multilib_copy_sources
 }
 
+multilib_src_configure() {
+       default
+       if multilib_is_native_abi; then
+               if use python; then
+                       distutils-r1_src_configure
+               fi
+       fi
+}
+
 multilib_src_compile() {
        tc-export AR CC PKG_CONFIG RANLIB
 
@@ -150,6 +166,13 @@ python_install() {
        dosym -r "$(python_get_sitedir)/selinux/_selinux${pycext}" 
"$(python_get_sitedir)/_selinux${pycext}"
 }
 
+multilib_src_test() {
+       default
+       if use python; then
+               distutils-r1_src_test
+       fi
+}
+
 pkg_postinst() {
        # Fix bug 473502
        for POLTYPE in ${POLICY_TYPES};

Reply via email to