1 |
Warn if python_foreach_impl is called directly from within a phase |
2 |
function that is already covered by a distutils-r1 sub-phase. |
3 |
|
4 |
Signed-off-by: Michał Górny <mgorny@g.o> |
5 |
--- |
6 |
eclass/distutils-r1.eclass | 1 + |
7 |
eclass/python-r1.eclass | 18 ++++++++++++++++++ |
8 |
2 files changed, 19 insertions(+) |
9 |
|
10 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
11 |
index 0e069597b3ab..0696b096b3c3 100644 |
12 |
--- a/eclass/distutils-r1.eclass |
13 |
+++ b/eclass/distutils-r1.eclass |
14 |
@@ -1750,6 +1750,7 @@ _distutils-r1_run_foreach_impl() { |
15 |
set -- distutils-r1_run_phase "${@}" |
16 |
|
17 |
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then |
18 |
+ local _DISTUTILS_CALLING_FOREACH_IMPL=1 |
19 |
python_foreach_impl "${@}" |
20 |
else |
21 |
if [[ ! ${EPYTHON} ]]; then |
22 |
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass |
23 |
index 2f8cfa0316d9..3471e17bdde6 100644 |
24 |
--- a/eclass/python-r1.eclass |
25 |
+++ b/eclass/python-r1.eclass |
26 |
@@ -625,6 +625,24 @@ _python_multibuild_wrapper() { |
27 |
python_foreach_impl() { |
28 |
debug-print-function ${FUNCNAME} "${@}" |
29 |
|
30 |
+ if [[ ${_DISTUTILS_R1} ]]; then |
31 |
+ if has "${EBUILD_PHASE}" prepare configure compile test install && |
32 |
+ [[ ! ${_DISTUTILS_CALLING_FOREACH_IMPL} && |
33 |
+ ! ${_DISTUTILS_FOREACH_IMPL_WARNED} ]] |
34 |
+ then |
35 |
+ eqawarn "python_foreach_impl has been called directly while using distutils-r1." |
36 |
+ eqawarn "Please redefine python_*() phase functions to meet your expectations" |
37 |
+ eqawarn "instead." |
38 |
+ _DISTUTILS_FOREACH_IMPL_WARNED=1 |
39 |
+ |
40 |
+ if ! has "${EAPI}" 6 7 8; then |
41 |
+ die "Calling python_foreach_impl from distutils-r1 is banned in EAPI ${EAPI}" |
42 |
+ fi |
43 |
+ fi |
44 |
+ # undo the eclass-set value to catch nested calls |
45 |
+ local _DISTUTILS_CALLING_FOREACH_IMPL= |
46 |
+ fi |
47 |
+ |
48 |
local MULTIBUILD_VARIANTS |
49 |
_python_obtain_impls |
50 |
|
51 |
-- |
52 |
2.35.1 |