commit:     9fb77f35a048dfcea2cc44486382c9de765befc7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun May  8 11:30:59 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May  9 20:31:51 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9fb77f35

distutils-r1.eclass: Support DISTUTILS_ARGS in PEP517 mode

Use gpep517 --config-json support to pass DISTUTILS_ARGS in PEP517 mode.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/distutils-r1.eclass | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 1573d803f3f6..e9a28056e9cc 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1091,12 +1091,38 @@ distutils_pep517_install() {
        local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel
        mkdir -p "${WHEEL_BUILD_DIR}" || die
 
+       if [[ -n ${mydistutilsargs[@]} ]]; then
+               die "mydistutilsargs are banned in PEP517 mode (use 
DISTUTILS_ARGS)"
+       fi
+
+       local config_settings=
+       if [[ -n ${DISTUTILS_ARGS[@]} ]]; then
+               case ${DISTUTILS_USE_PEP517} in
+                       setuptools)
+                               config_settings=$(
+                                       "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" 
<<-EOF || die
+                                               import json
+                                               import sys
+                                               
print(json.dumps({"--global-option": sys.argv[1:]}))
+                                       EOF
+                               )
+                               ;;
+                       *)
+                               die "DISTUTILS_ARGS are not supported by 
${DISTUTILS_USE_PEP517}"
+                               ;;
+               esac
+       fi
+
        local build_backend=$(_distutils-r1_get_backend)
        einfo "  Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}"
+       local config_args=()
+       [[ -n ${config_settings} ]] &&
+               config_args+=( --config-json "${config_settings}" )
        local wheel=$(
                gpep517 build-wheel --backend "${build_backend}" \
                                --output-fd 3 \
-                               --wheel-dir "${WHEEL_BUILD_DIR}" 3>&1 >&2 ||
+                               --wheel-dir "${WHEEL_BUILD_DIR}" \
+                               "${config_args[@]}" 3>&1 >&2 ||
                        die "Wheel build failed"
        )
        [[ -n ${wheel} ]] || die "No wheel name returned"
@@ -1181,10 +1207,6 @@ distutils-r1_python_compile() {
        esac
 
        if [[ ${DISTUTILS_USE_PEP517} ]]; then
-               if [[ -n ${DISTUTILS_ARGS[@]} || -n ${mydistutilsargs[@]} ]]; 
then
-                       die "DISTUTILS_ARGS are not supported in PEP-517 mode"
-               fi
-
                # python likes to compile any module it sees, which triggers 
sandbox
                # failures if some packages haven't compiled their modules yet.
                addpredict "${EPREFIX}/usr/lib/${EPYTHON}"

Reply via email to