Move the EPYTHON validity check from _python_EPYTHON_supported()
to python_setup() where it belongs.  This avoids unnecessarily retesting
implementations taken from PYTHON_COMPAT and paves the way towards
moving the common logic to python-utils-r1.

Signed-off-by: Michał Górny <mgo...@gentoo.org>
---
 eclass/python-any-r1.eclass | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 282c449f2a03..4c832384ed7a 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -283,28 +283,15 @@ _python_EPYTHON_supported() {
        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
+       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
-       elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
-               ewarn "Invalid EPYTHON: ${EPYTHON}"
+
+               return 0
        fi
        return 1
 }
@@ -338,7 +325,12 @@ python_setup() {
 
        # first, try ${EPYTHON}... maybe it's good enough for us.
        if [[ ${EPYTHON} ]]; then
-               if _python_EPYTHON_supported "${EPYTHON}"; then
+               local impl=${EPYTHON/./_}
+               if ! has "${impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
+                       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
                        _python_export EPYTHON PYTHON
                        _python_wrapper_setup
                        einfo "Using ${EPYTHON} to build"
-- 
2.35.1


Reply via email to