Gentoo Archives: gentoo-dev

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

Attachments

File name MIME type
signature.asc application/pgp-signature