1 |
Add a new DISTUTILS_USE_SETUPTOOLS top variable, and make it default |
2 |
to BDEPEND-ing on dev-python/setuptools (which should be correct |
3 |
for the majority of packages). Packages that either need RDEPEND |
4 |
or no dependency at all can override it. |
5 |
|
6 |
Also add a check for correct value in esetup.py. This should make it |
7 |
easy for developers to adjust the new variable in their packages. |
8 |
|
9 |
Signed-off-by: Michał Górny <mgorny@g.o> |
10 |
--- |
11 |
eclass/distutils-r1.eclass | 82 +++++++++++++++++++++++++++++++++++--- |
12 |
1 file changed, 76 insertions(+), 6 deletions(-) |
13 |
|
14 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
15 |
index f44f0aee9c21..083a72bd0589 100644 |
16 |
--- a/eclass/distutils-r1.eclass |
17 |
+++ b/eclass/distutils-r1.eclass |
18 |
@@ -77,9 +77,23 @@ esac |
19 |
# to be exported. It must be run in order for the eclass functions |
20 |
# to function properly. |
21 |
|
22 |
+# @ECLASS-VARIABLE: DISTUTILS_USE_SETUPTOOLS |
23 |
+# @PRE_INHERIT |
24 |
+# @DESCRIPTION: |
25 |
+# Controls adding dev-python/setuptools dependency. The allowed values |
26 |
+# are: |
27 |
+# |
28 |
+# - no -- do not add the dependency (pure distutils package) |
29 |
+# - bdepend -- add it to BDEPEND (the default) |
30 |
+# - rdepend -- add it to BDEPEND+RDEPEND (when using entry_points) |
31 |
+# |
32 |
+# This variable is effective only if DISTUTILS_OPTIONAL is disabled. |
33 |
+# It needs to be set before the inherit line. |
34 |
+: ${DISTUTILS_USE_SETUPTOOLS:=bdepend} |
35 |
+ |
36 |
if [[ ! ${_DISTUTILS_R1} ]]; then |
37 |
|
38 |
-[[ ${EAPI} == [45] ]] && inherit eutils |
39 |
+[[ ${EAPI} == [456] ]] && inherit eutils |
40 |
[[ ${EAPI} == [56] ]] && inherit xdg-utils |
41 |
inherit multiprocessing toolchain-funcs |
42 |
|
43 |
@@ -97,15 +111,35 @@ fi |
44 |
|
45 |
if [[ ! ${_DISTUTILS_R1} ]]; then |
46 |
|
47 |
-if [[ ! ${DISTUTILS_OPTIONAL} ]]; then |
48 |
- RDEPEND=${PYTHON_DEPS} |
49 |
+_distutils_set_globals() { |
50 |
+ local rdep=${PYTHON_DEPS} |
51 |
+ local bdep=${rdep} |
52 |
+ |
53 |
+ case ${DISTUTILS_USE_SETUPTOOLS} in |
54 |
+ no) |
55 |
+ ;; |
56 |
+ bdepend) |
57 |
+ bdep+=" dev-python/setuptools[${PYTHON_USEDEP}]" |
58 |
+ ;; |
59 |
+ rdepend) |
60 |
+ bdep+=" dev-python/setuptools[${PYTHON_USEDEP}]" |
61 |
+ rdep+=" dev-python/setuptools[${PYTHON_USEDEP}]" |
62 |
+ ;; |
63 |
+ *) |
64 |
+ die "Invalid DISTUTILS_USE_SETUPTOOLS=${DISTUTILS_USE_SETUPTOOLS}" |
65 |
+ ;; |
66 |
+ esac |
67 |
+ |
68 |
+ RDEPEND=${rdep} |
69 |
if [[ ${EAPI} != [56] ]]; then |
70 |
- BDEPEND=${PYTHON_DEPS} |
71 |
+ BDEPEND=${bdep} |
72 |
else |
73 |
- DEPEND=${PYTHON_DEPS} |
74 |
+ DEPEND=${bdep} |
75 |
fi |
76 |
REQUIRED_USE=${PYTHON_REQUIRED_USE} |
77 |
-fi |
78 |
+} |
79 |
+[[ ! ${DISTUTILS_OPTIONAL} ]] && _distutils_set_globals |
80 |
+unset -f _distutils_set_globals |
81 |
|
82 |
# @ECLASS-VARIABLE: PATCHES |
83 |
# @DEFAULT_UNSET |
84 |
@@ -395,6 +429,41 @@ distutils_enable_tests() { |
85 |
return 0 |
86 |
} |
87 |
|
88 |
+# @FUNCTION: _distutils-r1_verify_use_setuptools |
89 |
+# @INTERNAL |
90 |
+# @DESCRIPTION: |
91 |
+# Check setup.py for signs that DISTUTILS_USE_SETUPTOOLS have been set |
92 |
+# incorrectly. |
93 |
+_distutils_verify_use_setuptools() { |
94 |
+ [[ ${DISTUTILS_OPTIONAL} ]] && return |
95 |
+ |
96 |
+ # ok, those are cheap greps. we can try toimprove them if we hit |
97 |
+ # false positives. |
98 |
+ local expected=no |
99 |
+ if [[ ${CATEGORY}/${PN} == dev-python/setuptools ]]; then |
100 |
+ # as a special case, setuptools provides itself ;-) |
101 |
+ : |
102 |
+ elif grep -E -q -s '(from|import)\s+setuptools' setup.py; then |
103 |
+ if grep -E -q -s 'entry_points\s+=' setup.py; then |
104 |
+ expected=rdepend |
105 |
+ else |
106 |
+ expected=bdepend |
107 |
+ fi |
108 |
+ fi |
109 |
+ |
110 |
+ if [[ ${DISTUTILS_USE_SETUPTOOLS} != ${expected} ]]; then |
111 |
+ if [[ ! ${_DISTUTILS_SETUPTOOLS_WARNED} ]]; then |
112 |
+ _DISTUTILS_SETUPTOOLS_WARNED=1 |
113 |
+ local def= |
114 |
+ [[ ${DISTUTILS_USE_SETUPTOOLS} == bdepend ]] && def=' (default?)' |
115 |
+ |
116 |
+ eqawarn "DISTUTILS_USE_SETUPTOOLS value is probably incorrect" |
117 |
+ eqawarn " value: DISTUTILS_USE_SETUPTOOLS=${DISTUTILS_USE_SETUPTOOLS}${def}" |
118 |
+ eqawarn " expected: DISTUTILS_USE_SETUPTOOLS=${expected}" |
119 |
+ fi |
120 |
+ fi |
121 |
+} |
122 |
+ |
123 |
# @FUNCTION: esetup.py |
124 |
# @USAGE: [<args>...] |
125 |
# @DESCRIPTION: |
126 |
@@ -417,6 +486,7 @@ esetup.py() { |
127 |
[[ ${EAPI} != [45] ]] && die_args+=( -n ) |
128 |
|
129 |
[[ ${BUILD_DIR} ]] && _distutils-r1_create_setup_cfg |
130 |
+ _distutils_verify_use_setuptools |
131 |
|
132 |
set -- "${EPYTHON:-python}" setup.py "${mydistutilsargs[@]}" "${@}" |
133 |
|
134 |
-- |
135 |
2.24.0 |