Rewrite the python_*_all() phase running code to reuse python_setup instead of hacking on top of python_foreach_impl. The resulting code is a bit simpler but most importantly, it avoids duplication of code from python-r1 and ensures that distutils-r1 common phases are directly altered by changes in python_setup.
The code still needs to reimplement some of the internals. However, it is mostly limited to code specific to distutils-r1, and should be more maintainable. --- eclass/distutils-r1.eclass | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index e79f86bab12d..167af95eaed6 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -672,20 +672,20 @@ distutils-r1_run_phase() { _distutils-r1_run_common_phase() { local DISTUTILS_ORIG_BUILD_DIR=${BUILD_DIR} - if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then - local best_impl patterns=( "${DISTUTILS_ALL_SUBPHASE_IMPLS[@]-*}" ) - _distutils_try_impl() { - if _python_impl_matches "${EPYTHON}" "${patterns[@]}"; then - best_impl=${MULTIBUILD_VARIANT} - fi - } - python_foreach_impl _distutils_try_impl - unset -f _distutils_try_impl - - local PYTHON_COMPAT=( "${best_impl}" ) + if [[ ${DISTUTILS_SINGLE_IMPL} ]]; then + # reuse the dedicated code branch + _distutils-r1_run_foreach_impl "${@}" + else + local -x EPYTHON PYTHON + local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH} + python_setup "${DISTUTILS_ALL_SUBPHASE_IMPLS[@]}" + + local MULTIBUILD_VARIANTS=( "${EPYTHON/./_}" ) + # store for restoring after distutils-r1_run_phase. + local _DISTUTILS_INITIAL_CWD=${PWD} + multibuild_foreach_variant \ + distutils-r1_run_phase "${@}" fi - - _distutils-r1_run_foreach_impl "${@}" } # @FUNCTION: _distutils-r1_run_foreach_impl -- 2.13.0