Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] distutils-r1.eclass: Support DISTUTILS_ARGS in PEP517 mode
Date: Sun, 08 May 2022 18:29:04
Message-Id: 20220508182708.4161-1-mgorny@gentoo.org
1 Use gpep517 --config-json support to pass DISTUTILS_ARGS in PEP517 mode.
2
3 Signed-off-by: Michał Górny <mgorny@g.o>
4 ---
5 eclass/distutils-r1.eclass | 32 +++++++++++++++++++++++++++-----
6 1 file changed, 27 insertions(+), 5 deletions(-)
7
8 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
9 index 1573d803f3f6..e9a28056e9cc 100644
10 --- a/eclass/distutils-r1.eclass
11 +++ b/eclass/distutils-r1.eclass
12 @@ -1091,12 +1091,38 @@ distutils_pep517_install() {
13 local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel
14 mkdir -p "${WHEEL_BUILD_DIR}" || die
15
16 + if [[ -n ${mydistutilsargs[@]} ]]; then
17 + die "mydistutilsargs are banned in PEP517 mode (use DISTUTILS_ARGS)"
18 + fi
19 +
20 + local config_settings=
21 + if [[ -n ${DISTUTILS_ARGS[@]} ]]; then
22 + case ${DISTUTILS_USE_PEP517} in
23 + setuptools)
24 + config_settings=$(
25 + "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die
26 + import json
27 + import sys
28 + print(json.dumps({"--global-option": sys.argv[1:]}))
29 + EOF
30 + )
31 + ;;
32 + *)
33 + die "DISTUTILS_ARGS are not supported by ${DISTUTILS_USE_PEP517}"
34 + ;;
35 + esac
36 + fi
37 +
38 local build_backend=$(_distutils-r1_get_backend)
39 einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}"
40 + local config_args=()
41 + [[ -n ${config_settings} ]] &&
42 + config_args+=( --config-json "${config_settings}" )
43 local wheel=$(
44 gpep517 build-wheel --backend "${build_backend}" \
45 --output-fd 3 \
46 - --wheel-dir "${WHEEL_BUILD_DIR}" 3>&1 >&2 ||
47 + --wheel-dir "${WHEEL_BUILD_DIR}" \
48 + "${config_args[@]}" 3>&1 >&2 ||
49 die "Wheel build failed"
50 )
51 [[ -n ${wheel} ]] || die "No wheel name returned"
52 @@ -1181,10 +1207,6 @@ distutils-r1_python_compile() {
53 esac
54
55 if [[ ${DISTUTILS_USE_PEP517} ]]; then
56 - if [[ -n ${DISTUTILS_ARGS[@]} || -n ${mydistutilsargs[@]} ]]; then
57 - die "DISTUTILS_ARGS are not supported in PEP-517 mode"
58 - fi
59 -
60 # python likes to compile any module it sees, which triggers sandbox
61 # failures if some packages haven't compiled their modules yet.
62 addpredict "${EPREFIX}/usr/lib/${EPYTHON}"
63 --
64 2.35.1

Replies