From c564d3748f1f53f423b76b742893f06f154bbc57 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Tue, 22 Mar 2022 15:28:01 +0100 Subject: [PATCH] eclass/python-any-r1: Sync with Gentoo It's from Gentoo commit d7317785d04e7de172de3bff05852fca3cd15af2. --- .../eclass/python-any-r1.eclass | 80 ++++++------------- 1 file changed, 26 insertions(+), 54 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/python-any-r1.eclass b/sdk_container/src/third_party/portage-stable/eclass/python-any-r1.eclass index 7af9474d9a..2051b5e89b 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/python-any-r1.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/python-any-r1.eclass @@ -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: -# @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