mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-15 08:56:58 +02:00
eclass/python-any-r1: Sync with Gentoo
It's from Gentoo commit d7317785d04e7de172de3bff05852fca3cd15af2.
This commit is contained in:
parent
7b5743bd5d
commit
c564d3748f
@ -1,4 +1,4 @@
|
||||
# Copyright 1999-2021 Gentoo Authors
|
||||
# Copyright 1999-2022 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
# @ECLASS: python-any-r1.eclass
|
||||
@ -36,7 +36,7 @@
|
||||
# both.
|
||||
#
|
||||
# For more information, please see the Python Guide:
|
||||
# https://dev.gentoo.org/~mgorny/python-guide/
|
||||
# https://projects.gentoo.org/python/guide/
|
||||
|
||||
case "${EAPI:-0}" in
|
||||
[0-5]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;;
|
||||
@ -58,7 +58,7 @@ fi
|
||||
|
||||
EXPORT_FUNCTIONS pkg_setup
|
||||
|
||||
# @ECLASS-VARIABLE: PYTHON_COMPAT
|
||||
# @ECLASS_VARIABLE: PYTHON_COMPAT
|
||||
# @REQUIRED
|
||||
# @DESCRIPTION:
|
||||
# This variable contains a list of Python implementations the package
|
||||
@ -70,7 +70,7 @@ EXPORT_FUNCTIONS pkg_setup
|
||||
# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
|
||||
# @CODE
|
||||
|
||||
# @ECLASS-VARIABLE: PYTHON_COMPAT_OVERRIDE
|
||||
# @ECLASS_VARIABLE: PYTHON_COMPAT_OVERRIDE
|
||||
# @USER_VARIABLE
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
@ -89,7 +89,7 @@ EXPORT_FUNCTIONS pkg_setup
|
||||
# PYTHON_COMPAT_OVERRIDE='pypy' emerge -1v dev-python/bar
|
||||
# @CODE
|
||||
|
||||
# @ECLASS-VARIABLE: PYTHON_REQ_USE
|
||||
# @ECLASS_VARIABLE: PYTHON_REQ_USE
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# The list of USEflags required to be enabled on the Python
|
||||
@ -107,7 +107,7 @@ EXPORT_FUNCTIONS pkg_setup
|
||||
# || ( dev-lang/python:X.Y[gdbm,ncurses(-)?] ... )
|
||||
# @CODE
|
||||
|
||||
# @ECLASS-VARIABLE: PYTHON_DEPS
|
||||
# @ECLASS_VARIABLE: PYTHON_DEPS
|
||||
# @OUTPUT_VARIABLE
|
||||
# @DESCRIPTION:
|
||||
# This is an eclass-generated Python dependency string for all
|
||||
@ -126,7 +126,7 @@ EXPORT_FUNCTIONS pkg_setup
|
||||
# dev-lang/python:2.6[gdbm] )
|
||||
# @CODE
|
||||
|
||||
# @ECLASS-VARIABLE: PYTHON_USEDEP
|
||||
# @ECLASS_VARIABLE: PYTHON_USEDEP
|
||||
# @OUTPUT_VARIABLE
|
||||
# @DESCRIPTION:
|
||||
# An eclass-generated USE-dependency string for the currently tested
|
||||
@ -148,7 +148,7 @@ EXPORT_FUNCTIONS pkg_setup
|
||||
# python_targets_python3_7(-)
|
||||
# @CODE
|
||||
|
||||
# @ECLASS-VARIABLE: PYTHON_SINGLE_USEDEP
|
||||
# @ECLASS_VARIABLE: PYTHON_SINGLE_USEDEP
|
||||
# @OUTPUT_VARIABLE
|
||||
# @DESCRIPTION:
|
||||
# An eclass-generated USE-dependency string for the currently tested
|
||||
@ -271,44 +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/./_}
|
||||
|
||||
case "${i}" in
|
||||
python*|jython*|pypy*)
|
||||
;;
|
||||
*)
|
||||
ewarn "Invalid EPYTHON: ${EPYTHON}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if has "${i}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
|
||||
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
|
||||
elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
|
||||
ewarn "Invalid EPYTHON: ${EPYTHON}"
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# @FUNCTION: python_setup
|
||||
# @DESCRIPTION:
|
||||
# Determine what the best installed (and supported) Python
|
||||
@ -332,27 +294,37 @@ python_setup() {
|
||||
|
||||
_python_export "${impls[0]}" EPYTHON PYTHON
|
||||
_python_wrapper_setup
|
||||
einfo "Using ${EPYTHON} to build"
|
||||
einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT_OVERRIDE)"
|
||||
return
|
||||
fi
|
||||
|
||||
# first, try ${EPYTHON}... maybe it's good enough for us.
|
||||
if [[ ${EPYTHON} ]]; then
|
||||
if _python_EPYTHON_supported "${EPYTHON}"; then
|
||||
local epython_impl=${EPYTHON/./_}
|
||||
if [[ ${epython_impl} ]]; then
|
||||
if ! has "${epython_impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
|
||||
if ! has "${epython_impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
|
||||
ewarn "Invalid EPYTHON: ${EPYTHON}"
|
||||
else
|
||||
einfo "EPYTHON (${EPYTHON}) not supported by the package"
|
||||
fi
|
||||
elif _python_run_check_deps "${epython_impl}"; then
|
||||
_python_export EPYTHON PYTHON
|
||||
_python_wrapper_setup
|
||||
einfo "Using ${EPYTHON} to build"
|
||||
einfo "Using ${EPYTHON} to build (via EPYTHON)"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# fallback to best installed impl.
|
||||
# fallback to the 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]}
|
||||
# avoid checking EPYTHON twice
|
||||
[[ ${impl} == ${epython_impl} ]] && continue
|
||||
_python_export "${impl}" EPYTHON PYTHON
|
||||
if _python_run_check_deps "${impl}"; then
|
||||
_python_wrapper_setup
|
||||
einfo "Using ${EPYTHON} to build"
|
||||
einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT iteration)"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user