commit:     920edc504064fa38caa462b4d378114599f65925
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 10 13:51:03 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Mar 12 05:08:04 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=920edc50

distutils-r1.eclass: Set setuptools build config for all backends

Create the build config and set DIST_EXTRA_CONFIG independently
of the PEP517 backend used (but only in PEP517 mode).  This ensures
that our build directory (and parallel build) is respected when backend
values other than `setuptools` are used, particularly standalone build
in dev-python/setuptools, custom backends wrapping setuptools and other
PEP517 that might use setuptools internally.

As an immediate benefit, this stops new versions
of dev-python/setuptools from installing their `build` tree
into site-packages.  Thanks to Eli Schwartz for noticing this
and bringing to our attention.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/35695
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/distutils-r1.eclass | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index e0c54d81a846..9be994595529 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1505,32 +1505,28 @@ distutils-r1_python_compile() {
 
        _python_check_EPYTHON
 
-       case ${DISTUTILS_USE_PEP517:-setuptools} in
-               setuptools)
-                       # call setup.py build when using setuptools (either via 
PEP517
-                       # or in legacy mode)
-
-                       # distutils is parallel-capable since py3.5
-                       local jobs=$(makeopts_jobs "${MAKEOPTS} ${*}")
-
-                       if [[ ${DISTUTILS_USE_PEP517} ]]; then
-                               mkdir -p "${BUILD_DIR}" || die
-                               local -x 
DIST_EXTRA_CONFIG="${BUILD_DIR}/extra-setup.cfg"
-                               cat > "${DIST_EXTRA_CONFIG}" <<-EOF || die
-                                       [build]
-                                       build_base = ${BUILD_DIR}/build
-
-                                       [build_ext]
-                                       parallel = ${jobs}
-                               EOF
-                       else
-                               _distutils-r1_copy_egg_info
-                               esetup.py build -j "${jobs}" "${@}"
-                       fi
-                       ;;
+       case ${DISTUTILS_USE_PEP517:-unset} in
                no)
                        return
                        ;;
+               unset)
+                       # legacy mode
+                       _distutils-r1_copy_egg_info
+                       esetup.py build -j "$(makeopts_jobs "${MAKEOPTS} 
${*}")" "${@}"
+                       ;;
+               *)
+                       # we do this for all build systems, since other backends
+                       # and custom hooks may wrap setuptools
+                       mkdir -p "${BUILD_DIR}" || die
+                       local -x 
DIST_EXTRA_CONFIG="${BUILD_DIR}/extra-setup.cfg"
+                       cat > "${DIST_EXTRA_CONFIG}" <<-EOF || die
+                               [build]
+                               build_base = ${BUILD_DIR}/build
+
+                               [build_ext]
+                               parallel = $(makeopts_jobs "${MAKEOPTS} ${*}")
+                       EOF
+                       ;;
        esac
 
        if [[ ${DISTUTILS_USE_PEP517} ]]; then

Reply via email to