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 27/30] python-any-r1.eclass: Do not test EPYTHON twice
Date: Sun, 06 Feb 2022 12:57:14
Message-Id: 20220206124841.1299133-28-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 Avoid checking the implementation from EPYTHON via fallback iteration.
2 While there's no technical harm in doing that, now that we output
3 verbosely the users will notice ;-).
4
5 Signed-off-by: Michał Górny <mgorny@g.o>
6 ---
7 eclass/python-any-r1.eclass | 14 ++++++++------
8 1 file changed, 8 insertions(+), 6 deletions(-)
9
10 diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
11 index 5c01e9eb6888..4e954f57cd2d 100644
12 --- a/eclass/python-any-r1.eclass
13 +++ b/eclass/python-any-r1.eclass
14 @@ -299,13 +299,13 @@ python_setup() {
15 fi
16
17 # first, try ${EPYTHON}... maybe it's good enough for us.
18 - if [[ ${EPYTHON} ]]; then
19 - local impl=${EPYTHON/./_}
20 - if ! has "${impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
21 + local epython_impl=${EPYTHON/./_}
22 + if [[ ${epython_impl} ]]; then
23 + if ! has "${epython_impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
24 einfo "EPYTHON (${EPYTHON}) not supported by the package"
25 - elif ! has "${impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
26 + elif ! has "${epython_impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
27 ewarn "Invalid EPYTHON: ${EPYTHON}"
28 - elif _python_run_check_deps "${impl}"; then
29 + elif _python_run_check_deps "${epython_impl}"; then
30 _python_export EPYTHON PYTHON
31 _python_wrapper_setup
32 einfo "Using ${EPYTHON} to build (via EPYTHON)"
33 @@ -313,10 +313,12 @@ python_setup() {
34 fi
35 fi
36
37 - # fallback to best installed impl.
38 + # fallback to the best installed impl.
39 # (reverse iteration over _PYTHON_SUPPORTED_IMPLS)
40 for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
41 local impl=${_PYTHON_SUPPORTED_IMPLS[i]}
42 + # avoid checking EPYTHON twice
43 + [[ ${impl} == ${epython_impl} ]] && continue
44 _python_export "${impl}" EPYTHON PYTHON
45 if _python_run_check_deps "${impl}"; then
46 _python_wrapper_setup
47 --
48 2.35.1