Skip to content

Commit

Permalink
distutils-r1.eclass: Reuse python_setup for common phases
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgorny committed May 29, 2017
1 parent b003a0e commit 452f2b2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions eclass/distutils-r1.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 452f2b2

Please sign in to comment.