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 4/5] distutils-r1.eclass: Introduce sipbuild backend support
Date: Tue, 10 May 2022 21:13:43
Message-Id: 20220510211211.2091-5-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/5] distutils-r1.eclass: sipbuild PEP517 support by "Michał Górny"
1 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/distutils-r1.eclass | 53 ++++++++++++++++++++++++++++++++++++--
4 1 file changed, 51 insertions(+), 2 deletions(-)
5
6 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
7 index 17286070e712..0962ef5e2356 100644
8 --- a/eclass/distutils-r1.eclass
9 +++ b/eclass/distutils-r1.eclass
10 @@ -114,6 +114,8 @@ esac
11 #
12 # - setuptools - distutils or setuptools (incl. legacy mode)
13 #
14 +# - sip - sipbuild backend
15 +#
16 # - standalone - standalone build systems without external deps
17 # (used for bootstrapping).
18 #
19 @@ -227,6 +229,10 @@ _distutils_set_globals() {
20 >=dev-python/setuptools-60.5.0[${PYTHON_USEDEP}]
21 dev-python/wheel[${PYTHON_USEDEP}]'
22 ;;
23 + sip)
24 + bdep+='
25 + >=dev-python/sip-6.5.0-r1[${PYTHON_USEDEP}]'
26 + ;;
27 standalone)
28 ;;
29 *)
30 @@ -388,8 +394,19 @@ unset -f _distutils_set_globals
31 # @ECLASS_VARIABLE: DISTUTILS_ARGS
32 # @DEFAULT_UNSET
33 # @DESCRIPTION:
34 -# An array containing options to be passed to setup.py. They are passed
35 -# before the default arguments, i.e. before the first command.
36 +# An array containing options to be passed to the build system.
37 +# Supported by a subset of build systems used by the eclass.
38 +#
39 +# For setuptools, the arguments will be passed as first parameters
40 +# to setup.py invocations (via esetup.py), as well as to the PEP517
41 +# backend. For future compatibility, only global options should be used
42 +# and specifying commands should be avoided.
43 +#
44 +# For sip, the options are passed to the PEP517 backend in a form
45 +# resembling sip-build calls. Options taking arguments need to
46 +# be specified in the "--key=value" form, while flag options as "--key".
47 +# If an option takes multiple arguments, it can be specified multiple
48 +# times, same as for sip-build.
49 #
50 # Example:
51 # @CODE
52 @@ -920,6 +937,11 @@ _distutils-r1_print_package_versions() {
53 dev-python/wheel
54 )
55 ;;
56 + sip)
57 + packages+=(
58 + dev-python/sip
59 + )
60 + ;;
61 esac
62 else
63 case ${DISTUTILS_USE_SETUPTOOLS} in
64 @@ -1104,6 +1126,9 @@ _distutils-r1_backend_to_key() {
65 setuptools.build_meta|setuptools.build_meta:__legacy__)
66 echo setuptools
67 ;;
68 + sipbuild.api)
69 + echo sip
70 + ;;
71 *)
72 die "Unknown backend: ${backend}"
73 ;;
74 @@ -1202,6 +1227,30 @@ distutils_pep517_install() {
75 EOF
76 )
77 ;;
78 + sip)
79 + # NB: for practical reasons, we support only --foo=bar,
80 + # not --foo bar
81 + local arg
82 + for arg in "${DISTUTILS_ARGS[@]}"; do
83 + [[ ${arg} != -* ]] &&
84 + die "Bare arguments in DISTUTILS_ARGS unsupported: ${arg}"
85 + done
86 +
87 + config_settings=$(
88 + "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die
89 + import collections
90 + import json
91 + import sys
92 +
93 + args = collections.defaultdict(list)
94 + for arg in (x.split("=", 1) for x in sys.argv[1:]): \
95 + args[arg[0]].extend(
96 + [arg[1]] if len(arg) > 1 else [])
97 +
98 + print(json.dumps(args))
99 + EOF
100 + )
101 + ;;
102 *)
103 die "DISTUTILS_ARGS are not supported by ${DISTUTILS_USE_PEP517}"
104 ;;
105 --
106 2.35.1