mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-11-24 11:37:20 -08:00
python-utils-r1.eclass: Add function to run python_check_deps()
Add a function encompassing the common logic to run python_check_deps() from python-any-r1 and python-r1. Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
@@ -271,31 +271,6 @@ python_gen_any_dep() {
|
||||
echo "|| ( ${out})"
|
||||
}
|
||||
|
||||
# @FUNCTION: _python_EPYTHON_supported
|
||||
# @USAGE: <epython>
|
||||
# @INTERNAL
|
||||
# @DESCRIPTION:
|
||||
# Check whether the specified implementation is supported by package
|
||||
# (specified in PYTHON_COMPAT). Calls python_check_deps() if declared.
|
||||
_python_EPYTHON_supported() {
|
||||
debug-print-function ${FUNCNAME} "${@}"
|
||||
|
||||
local EPYTHON=${1}
|
||||
local i=${EPYTHON/./_}
|
||||
|
||||
if python_is_installed "${i}"; then
|
||||
if declare -f python_check_deps >/dev/null; then
|
||||
local PYTHON_USEDEP="python_targets_${i}(-)"
|
||||
local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
|
||||
python_check_deps
|
||||
return ${?}
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# @FUNCTION: python_setup
|
||||
# @DESCRIPTION:
|
||||
# Determine what the best installed (and supported) Python
|
||||
@@ -330,7 +305,7 @@ python_setup() {
|
||||
einfo "EPYTHON (${EPYTHON}) not supported by the package"
|
||||
elif ! has "${impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
|
||||
ewarn "Invalid EPYTHON: ${EPYTHON}"
|
||||
elif _python_EPYTHON_supported "${EPYTHON}"; then
|
||||
elif _python_run_check_deps "${impl}"; then
|
||||
_python_export EPYTHON PYTHON
|
||||
_python_wrapper_setup
|
||||
einfo "Using ${EPYTHON} to build"
|
||||
@@ -341,8 +316,9 @@ python_setup() {
|
||||
# fallback to best installed impl.
|
||||
# (reverse iteration over _PYTHON_SUPPORTED_IMPLS)
|
||||
for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
|
||||
_python_export "${_PYTHON_SUPPORTED_IMPLS[i]}" EPYTHON PYTHON
|
||||
if _python_EPYTHON_supported "${EPYTHON}"; then
|
||||
local impl=${_PYTHON_SUPPORTED_IMPLS[i]}
|
||||
_python_export "${impl}" EPYTHON PYTHON
|
||||
if _python_run_check_deps "${impl}"; then
|
||||
_python_wrapper_setup
|
||||
einfo "Using ${EPYTHON} to build"
|
||||
return
|
||||
|
||||
@@ -740,12 +740,7 @@ python_setup() {
|
||||
|
||||
# if python_check_deps() is declared, switch into any-of mode
|
||||
if [[ ${has_check_deps} ]]; then
|
||||
# first check if the interpreter is installed
|
||||
python_is_installed "${impl}" || continue
|
||||
# then run python_check_deps
|
||||
local PYTHON_USEDEP="python_targets_${impl}(-)"
|
||||
local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)"
|
||||
python_check_deps || continue
|
||||
_python_run_check_deps "${impl}" || continue
|
||||
fi
|
||||
|
||||
found=1
|
||||
|
||||
@@ -1368,5 +1368,25 @@ eunittest() {
|
||||
return ${?}
|
||||
}
|
||||
|
||||
# @FUNCTION: _python_run_check_deps
|
||||
# @INTERNAL
|
||||
# @USAGE: <impl>
|
||||
# @DESCRIPTION:
|
||||
# Verify whether <impl> is an acceptable choice to run any-r1 style
|
||||
# code. Checks whether the interpreter is installed, runs
|
||||
# python_check_deps() if declared.
|
||||
_python_run_check_deps() {
|
||||
debug-print-function ${FUNCNAME} "${@}"
|
||||
|
||||
local impl=${1}
|
||||
|
||||
python_is_installed "${impl}" || return 1
|
||||
declare -f python_check_deps >/dev/null || return 0
|
||||
|
||||
local PYTHON_USEDEP="python_targets_${impl}(-)"
|
||||
local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)"
|
||||
python_check_deps
|
||||
}
|
||||
|
||||
_PYTHON_UTILS_R1=1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user