1 |
Inline the logic needed to iterate over implementations directly into |
2 |
python_setup instead of using python_foreach_impl. This is mostly NFC, |
3 |
except that we iterate in reverse order now -- that is, we start at |
4 |
the newest implementation and stop at the first one that works for us. |
5 |
Previously we (implicitly) started at the oldest implementation, checked |
6 |
all implementation and used the last one (i.e. the newest) that worked. |
7 |
|
8 |
More importantly, the new code makes it possible to alter the logic more |
9 |
easily and avoid relying on implementation of python_foreach_impl(). |
10 |
--- |
11 |
eclass/python-r1.eclass | 35 ++++++++++++++++++++++++++--------- |
12 |
1 file changed, 26 insertions(+), 9 deletions(-) |
13 |
|
14 |
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass |
15 |
index ae9e3806e729..9c37a20f7c2e 100644 |
16 |
--- a/eclass/python-r1.eclass |
17 |
+++ b/eclass/python-r1.eclass |
18 |
@@ -597,16 +597,34 @@ python_foreach_impl() { |
19 |
python_setup() { |
20 |
debug-print-function ${FUNCNAME} "${@}" |
21 |
|
22 |
- local best_impl patterns=( "${@-*}" ) |
23 |
- _python_try_impl() { |
24 |
- if _python_impl_matches "${EPYTHON}" "${patterns[@]}"; then |
25 |
- best_impl=${EPYTHON} |
26 |
+ _python_validate_useflags |
27 |
+ local pycompat=( "${PYTHON_COMPAT[@]}" ) |
28 |
+ if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then |
29 |
+ pycompat=( ${PYTHON_COMPAT_OVERRIDE} ) |
30 |
+ fi |
31 |
+ |
32 |
+ # (reverse iteration -- newest impl first) |
33 |
+ local found |
34 |
+ for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do |
35 |
+ local impl=${_PYTHON_SUPPORTED_IMPLS[i]} |
36 |
+ |
37 |
+ # check PYTHON_COMPAT[_OVERRIDE] |
38 |
+ has "${impl}" "${pycompat[@]}" || continue |
39 |
+ |
40 |
+ # match USE flags only if override is not in effect |
41 |
+ if [[ ! ${PYTHON_COMPAT_OVERRIDE} ]]; then |
42 |
+ use "python_targets_${impl}" || continue |
43 |
fi |
44 |
- } |
45 |
- python_foreach_impl _python_try_impl |
46 |
- unset -f _python_try_impl |
47 |
|
48 |
- if [[ ! ${best_impl} ]]; then |
49 |
+ # check patterns |
50 |
+ _python_impl_matches "${impl}" "${@-*}" || continue |
51 |
+ |
52 |
+ python_export "${impl}" EPYTHON PYTHON |
53 |
+ found=1 |
54 |
+ break |
55 |
+ done |
56 |
+ |
57 |
+ if [[ ! ${found} ]]; then |
58 |
eerror "${FUNCNAME}: none of the enabled implementation matched the patterns." |
59 |
eerror " patterns: ${@-'(*)'}" |
60 |
eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing." |
61 |
@@ -615,7 +633,6 @@ python_setup() { |
62 |
die "${FUNCNAME}: no enabled implementation satisfy requirements" |
63 |
fi |
64 |
|
65 |
- python_export "${best_impl}" EPYTHON PYTHON |
66 |
python_wrapper_setup |
67 |
} |
68 |
|
69 |
-- |
70 |
2.13.0 |