1 |
Add a function encompassing the common logic to run python_check_deps() |
2 |
from python-any-r1 and python-r1. |
3 |
|
4 |
Signed-off-by: Michał Górny <mgorny@g.o> |
5 |
--- |
6 |
eclass/python-any-r1.eclass | 32 ++++---------------------------- |
7 |
eclass/python-r1.eclass | 7 +------ |
8 |
eclass/python-utils-r1.eclass | 20 ++++++++++++++++++++ |
9 |
3 files changed, 25 insertions(+), 34 deletions(-) |
10 |
|
11 |
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass |
12 |
index 4c832384ed7a..8d3af399b4be 100644 |
13 |
--- a/eclass/python-any-r1.eclass |
14 |
+++ b/eclass/python-any-r1.eclass |
15 |
@@ -271,31 +271,6 @@ python_gen_any_dep() { |
16 |
echo "|| ( ${out})" |
17 |
} |
18 |
|
19 |
-# @FUNCTION: _python_EPYTHON_supported |
20 |
-# @USAGE: <epython> |
21 |
-# @INTERNAL |
22 |
-# @DESCRIPTION: |
23 |
-# Check whether the specified implementation is supported by package |
24 |
-# (specified in PYTHON_COMPAT). Calls python_check_deps() if declared. |
25 |
-_python_EPYTHON_supported() { |
26 |
- debug-print-function ${FUNCNAME} "${@}" |
27 |
- |
28 |
- local EPYTHON=${1} |
29 |
- local i=${EPYTHON/./_} |
30 |
- |
31 |
- if python_is_installed "${i}"; then |
32 |
- if declare -f python_check_deps >/dev/null; then |
33 |
- local PYTHON_USEDEP="python_targets_${i}(-)" |
34 |
- local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)" |
35 |
- python_check_deps |
36 |
- return ${?} |
37 |
- fi |
38 |
- |
39 |
- return 0 |
40 |
- fi |
41 |
- return 1 |
42 |
-} |
43 |
- |
44 |
# @FUNCTION: python_setup |
45 |
# @DESCRIPTION: |
46 |
# Determine what the best installed (and supported) Python |
47 |
@@ -330,7 +305,7 @@ python_setup() { |
48 |
einfo "EPYTHON (${EPYTHON}) not supported by the package" |
49 |
elif ! has "${impl}" "${_PYTHON_ALL_IMPLS[@]}"; then |
50 |
ewarn "Invalid EPYTHON: ${EPYTHON}" |
51 |
- elif _python_EPYTHON_supported "${EPYTHON}"; then |
52 |
+ elif _python_run_check_deps "${impl}"; then |
53 |
_python_export EPYTHON PYTHON |
54 |
_python_wrapper_setup |
55 |
einfo "Using ${EPYTHON} to build" |
56 |
@@ -341,8 +316,9 @@ python_setup() { |
57 |
# fallback to best installed impl. |
58 |
# (reverse iteration over _PYTHON_SUPPORTED_IMPLS) |
59 |
for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do |
60 |
- _python_export "${_PYTHON_SUPPORTED_IMPLS[i]}" EPYTHON PYTHON |
61 |
- if _python_EPYTHON_supported "${EPYTHON}"; then |
62 |
+ local impl=${_PYTHON_SUPPORTED_IMPLS[i]} |
63 |
+ _python_export "${impl}" EPYTHON PYTHON |
64 |
+ if _python_run_check_deps "${impl}"; then |
65 |
_python_wrapper_setup |
66 |
einfo "Using ${EPYTHON} to build" |
67 |
return |
68 |
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass |
69 |
index f9a9e9465b40..469c3014abfb 100644 |
70 |
--- a/eclass/python-r1.eclass |
71 |
+++ b/eclass/python-r1.eclass |
72 |
@@ -740,12 +740,7 @@ python_setup() { |
73 |
|
74 |
# if python_check_deps() is declared, switch into any-of mode |
75 |
if [[ ${has_check_deps} ]]; then |
76 |
- # first check if the interpreter is installed |
77 |
- python_is_installed "${impl}" || continue |
78 |
- # then run python_check_deps |
79 |
- local PYTHON_USEDEP="python_targets_${impl}(-)" |
80 |
- local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)" |
81 |
- python_check_deps || continue |
82 |
+ _python_run_check_deps "${impl}" || continue |
83 |
fi |
84 |
|
85 |
found=1 |
86 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
87 |
index c8367f8065f4..f8c0c00ce919 100644 |
88 |
--- a/eclass/python-utils-r1.eclass |
89 |
+++ b/eclass/python-utils-r1.eclass |
90 |
@@ -1368,5 +1368,25 @@ eunittest() { |
91 |
return ${?} |
92 |
} |
93 |
|
94 |
+# @FUNCTION: _python_run_check_deps |
95 |
+# @INTERNAL |
96 |
+# @USAGE: <impl> |
97 |
+# @DESCRIPTION: |
98 |
+# Verify whether <impl> is an acceptable choice to run any-r1 style |
99 |
+# code. Checks whether the interpreter is installed, runs |
100 |
+# python_check_deps() if declared. |
101 |
+_python_run_check_deps() { |
102 |
+ debug-print-function ${FUNCNAME} "${@}" |
103 |
+ |
104 |
+ local impl=${1} |
105 |
+ |
106 |
+ python_is_installed "${impl}" || return 1 |
107 |
+ declare -f python_check_deps >/dev/null || return 0 |
108 |
+ |
109 |
+ local PYTHON_USEDEP="python_targets_${impl}(-)" |
110 |
+ local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)" |
111 |
+ python_check_deps |
112 |
+} |
113 |
+ |
114 |
_PYTHON_UTILS_R1=1 |
115 |
fi |
116 |
-- |
117 |
2.35.1 |