commit: 150538e302a34e89b9364d63fadfb6683b3af2d6
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 9 05:51:13 2022 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jun 12 08:31:03 2022 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=150538e3
python-r1.eclass: Warn about direct foreach_impl calls in d-r1
Warn if python_foreach_impl is called directly from within a phase
function that is already covered by a distutils-r1 sub-phase.
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
eclass/distutils-r1.eclass | 1 +
eclass/python-r1.eclass | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index c4a46a620546..693b656b21bc 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1752,6 +1752,7 @@ _distutils-r1_run_foreach_impl() {
set -- distutils-r1_run_phase "${@}"
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+ local _DISTUTILS_CALLING_FOREACH_IMPL=1
python_foreach_impl "${@}"
else
if [[ ! ${EPYTHON} ]]; then
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 2f8cfa0316d9..3471e17bdde6 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -625,6 +625,24 @@ _python_multibuild_wrapper() {
python_foreach_impl() {
debug-print-function ${FUNCNAME} "${@}"
+ if [[ ${_DISTUTILS_R1} ]]; then
+ if has "${EBUILD_PHASE}" prepare configure compile test install
&&
+ [[ ! ${_DISTUTILS_CALLING_FOREACH_IMPL} &&
+ ! ${_DISTUTILS_FOREACH_IMPL_WARNED} ]]
+ then
+ eqawarn "python_foreach_impl has been called directly
while using distutils-r1."
+ eqawarn "Please redefine python_*() phase functions to
meet your expectations"
+ eqawarn "instead."
+ _DISTUTILS_FOREACH_IMPL_WARNED=1
+
+ if ! has "${EAPI}" 6 7 8; then
+ die "Calling python_foreach_impl from
distutils-r1 is banned in EAPI ${EAPI}"
+ fi
+ fi
+ # undo the eclass-set value to catch nested calls
+ local _DISTUTILS_CALLING_FOREACH_IMPL=
+ fi
+
local MULTIBUILD_VARIANTS
_python_obtain_impls