Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 06/30] python-any-r1.eclass: Move EPYTHON validity check to python_setup()
Date: Sun, 06 Feb 2022 12:51:11
Message-Id: 20220206124841.1299133-7-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/30] One batch of Python eclass updates to rule them all by "Michał Górny"
1 Move the EPYTHON validity check from _python_EPYTHON_supported()
2 to python_setup() where it belongs. This avoids unnecessarily retesting
3 implementations taken from PYTHON_COMPAT and paves the way towards
4 moving the common logic to python-utils-r1.
5
6 Signed-off-by: Michał Górny <mgorny@g.o>
7 ---
8 eclass/python-any-r1.eclass | 36 ++++++++++++++----------------------
9 1 file changed, 14 insertions(+), 22 deletions(-)
10
11 diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
12 index 282c449f2a03..4c832384ed7a 100644
13 --- a/eclass/python-any-r1.eclass
14 +++ b/eclass/python-any-r1.eclass
15 @@ -283,28 +283,15 @@ _python_EPYTHON_supported() {
16 local EPYTHON=${1}
17 local i=${EPYTHON/./_}
18
19 - case "${i}" in
20 - python*|jython*|pypy*)
21 - ;;
22 - *)
23 - ewarn "Invalid EPYTHON: ${EPYTHON}"
24 - return 1
25 - ;;
26 - esac
27 -
28 - if has "${i}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
29 - if python_is_installed "${i}"; then
30 - if declare -f python_check_deps >/dev/null; then
31 - local PYTHON_USEDEP="python_targets_${i}(-)"
32 - local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
33 - python_check_deps
34 - return ${?}
35 - fi
36 -
37 - return 0
38 + if python_is_installed "${i}"; then
39 + if declare -f python_check_deps >/dev/null; then
40 + local PYTHON_USEDEP="python_targets_${i}(-)"
41 + local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
42 + python_check_deps
43 + return ${?}
44 fi
45 - elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
46 - ewarn "Invalid EPYTHON: ${EPYTHON}"
47 +
48 + return 0
49 fi
50 return 1
51 }
52 @@ -338,7 +325,12 @@ python_setup() {
53
54 # first, try ${EPYTHON}... maybe it's good enough for us.
55 if [[ ${EPYTHON} ]]; then
56 - if _python_EPYTHON_supported "${EPYTHON}"; then
57 + local impl=${EPYTHON/./_}
58 + if ! has "${impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
59 + einfo "EPYTHON (${EPYTHON}) not supported by the package"
60 + elif ! has "${impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
61 + ewarn "Invalid EPYTHON: ${EPYTHON}"
62 + elif _python_EPYTHON_supported "${EPYTHON}"; then
63 _python_export EPYTHON PYTHON
64 _python_wrapper_setup
65 einfo "Using ${EPYTHON} to build"
66 --
67 2.35.1