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