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