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 2/7] distutils-r1.eclass: Pass options to meson-python backend
Date: Fri, 25 Nov 2022 17:05:59
Message-Id: 20221125170508.23064-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/7] distutils-r1.eclass: mesonpy option passing support + periodic cleanup by "Michał Górny"
1 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/distutils-r1.eclass | 50 +++++++++++++++++++++++++++++---------
4 1 file changed, 39 insertions(+), 11 deletions(-)
5
6 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
7 index 4cc117dfbd54..3ac06a458483 100644
8 --- a/eclass/distutils-r1.eclass
9 +++ b/eclass/distutils-r1.eclass
10 @@ -178,7 +178,7 @@ esac
11 if [[ ! ${_DISTUTILS_R1} ]]; then
12
13 [[ ${EAPI} == 6 ]] && inherit eutils xdg-utils
14 -inherit multibuild multiprocessing toolchain-funcs
15 +inherit multibuild multiprocessing ninja-utils toolchain-funcs
16
17 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
18 inherit python-r1
19 @@ -1319,9 +1319,34 @@ distutils_pep517_install() {
20 fi
21
22 local config_settings=
23 - if [[ -n ${DISTUTILS_ARGS[@]} ]]; then
24 - case ${DISTUTILS_USE_PEP517} in
25 - setuptools)
26 + case ${DISTUTILS_USE_PEP517} in
27 + meson-python)
28 + # TODO: remove the condition once we BDEP on >=0.11
29 + if has_version -b ">=dev-python/meson-python-0.11"; then
30 + local -x NINJAOPTS=$(get_NINJAOPTS)
31 + config_settings=$(
32 + "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die
33 + import json
34 + import os
35 + import shlex
36 + import sys
37 +
38 + ninjaopts = shlex.split(os.environ["NINJAOPTS"])
39 + print(json.dumps({
40 + "setup-args": sys.argv[1:],
41 + "compile-args": [
42 + "-v",
43 + f"--ninja-args={ninjaopts!r}",
44 + ],
45 + }))
46 + EOF
47 + )
48 + elif [[ -n ${DISTUTILS_ARGS[@]} ]]; then
49 + die "DISTUTILS_ARGS requires >=dev-python/meson-python-0.11 (missing BDEP?)"
50 + fi
51 + ;;
52 + setuptools)
53 + if [[ -n ${DISTUTILS_ARGS[@]} ]]; then
54 config_settings=$(
55 "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die
56 import json
57 @@ -1329,8 +1354,10 @@ distutils_pep517_install() {
58 print(json.dumps({"--global-option": sys.argv[1:]}))
59 EOF
60 )
61 - ;;
62 - sip)
63 + fi
64 + ;;
65 + sip)
66 + if [[ -n ${DISTUTILS_ARGS[@]} ]]; then
67 # NB: for practical reasons, we support only --foo=bar,
68 # not --foo bar
69 local arg
70 @@ -1353,12 +1380,13 @@ distutils_pep517_install() {
71 print(json.dumps(args))
72 EOF
73 )
74 - ;;
75 - *)
76 + fi
77 + ;;
78 + *)
79 + [[ -n ${DISTUTILS_ARGS[@]} ]] &&
80 die "DISTUTILS_ARGS are not supported by ${DISTUTILS_USE_PEP517}"
81 - ;;
82 - esac
83 - fi
84 + ;;
85 + esac
86
87 local build_backend=$(_distutils-r1_get_backend)
88 einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}"
89 --
90 2.38.1