1 |
commit: af76aa5899fa0c9acbefe94891449321f02f70cd |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Dec 17 21:15:56 2020 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 23 10:14:45 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=af76aa58 |
7 |
|
8 |
python-any-r1.eclass: Support PYTHON_SINGLE_USEDEP |
9 |
|
10 |
Closes: https://bugs.gentoo.org/713894 |
11 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
12 |
|
13 |
eclass/python-any-r1.eclass | 48 +++++++++++++++++++++++++++++++++++---------- |
14 |
1 file changed, 38 insertions(+), 10 deletions(-) |
15 |
|
16 |
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass |
17 |
index 9fd7fd6bc27..5f2dc5b8f38 100644 |
18 |
--- a/eclass/python-any-r1.eclass |
19 |
+++ b/eclass/python-any-r1.eclass |
20 |
@@ -24,9 +24,10 @@ |
21 |
# be called by the eclass with EPYTHON set to each matching Python |
22 |
# implementation and it is expected to check whether the implementation |
23 |
# fulfills the package requirements. You can use the locally exported |
24 |
-# PYTHON_USEDEP to check USE-dependencies of relevant packages. It |
25 |
-# should return a true value (0) if the Python implementation fulfills |
26 |
-# the requirements, a false value (non-zero) otherwise. |
27 |
+# PYTHON_USEDEP or PYTHON_SINGLE_USEDEP to check USE-dependencies |
28 |
+# of relevant packages. It should return a true value (0) if the Python |
29 |
+# implementation fulfills the requirements, a false value (non-zero) |
30 |
+# otherwise. |
31 |
# |
32 |
# Please note that python-any-r1 will always inherit python-utils-r1 |
33 |
# as well. Thus, all the functions defined there can be used in the |
34 |
@@ -131,8 +132,9 @@ EXPORT_FUNCTIONS pkg_setup |
35 |
# An eclass-generated USE-dependency string for the currently tested |
36 |
# implementation. It is set locally for python_check_deps() call. |
37 |
# |
38 |
-# The generate USE-flag list is compatible with packages using python-r1 |
39 |
-# eclass. It must not be used on packages using other eclasses. |
40 |
+# The generated USE-flag list is compatible with packages using |
41 |
+# python-r1 eclass. For python-single-r1 dependencies, |
42 |
+# use PYTHON_SINGLE_USEDEP. |
43 |
# |
44 |
# Example use: |
45 |
# @CODE |
46 |
@@ -146,6 +148,28 @@ EXPORT_FUNCTIONS pkg_setup |
47 |
# python_targets_python3_7(-),-python_single_target_python3_7(-) |
48 |
# @CODE |
49 |
|
50 |
+# @ECLASS-VARIABLE: PYTHON_SINGLE_USEDEP |
51 |
+# @OUTPUT_VARIABLE |
52 |
+# @DESCRIPTION: |
53 |
+# An eclass-generated USE-dependency string for the currently tested |
54 |
+# implementation. It is set locally for python_check_deps() call. |
55 |
+# |
56 |
+# The generated USE-flag list is compatible with packages using |
57 |
+# python-single-r1 eclass. For python-r1 dependencies, |
58 |
+# use PYTHON_USEDEP. |
59 |
+# |
60 |
+# Example use: |
61 |
+# @CODE |
62 |
+# python_check_deps() { |
63 |
+# has_version "dev-python/bar[${PYTHON_SINGLE_USEDEP}]" |
64 |
+# } |
65 |
+# @CODE |
66 |
+# |
67 |
+# Example value: |
68 |
+# @CODE |
69 |
+# python_single_target_python3_7(-) |
70 |
+# @CODE |
71 |
+ |
72 |
_python_any_set_globals() { |
73 |
local usestr deps i PYTHON_PKG_DEP |
74 |
[[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]" |
75 |
@@ -189,7 +213,8 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then |
76 |
# Generate an any-of dependency that enforces a version match between |
77 |
# the Python interpreter and Python packages. <dependency-block> needs |
78 |
# to list one or more dependencies with verbatim '${PYTHON_USEDEP}' |
79 |
-# references (quoted!) that will get expanded inside the function. |
80 |
+# or '${PYTHON_SINGLE_USEDEP}' references (quoted!) that will get |
81 |
+# expanded inside the function. |
82 |
# |
83 |
# This should be used along with an appropriate python_check_deps() |
84 |
# that checks which of the any-of blocks were matched. |
85 |
@@ -197,12 +222,12 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then |
86 |
# Example use: |
87 |
# @CODE |
88 |
# DEPEND="$(python_gen_any_dep ' |
89 |
-# dev-python/foo[${PYTHON_USEDEP}] |
90 |
+# dev-python/foo[${PYTHON_SINGLE_USEDEP}] |
91 |
# || ( dev-python/bar[${PYTHON_USEDEP}] |
92 |
# dev-python/baz[${PYTHON_USEDEP}] )')" |
93 |
# |
94 |
# python_check_deps() { |
95 |
-# has_version "dev-python/foo[${PYTHON_USEDEP}]" \ |
96 |
+# has_version "dev-python/foo[${PYTHON_SINGLE_USEDEP}]" \ |
97 |
# && { has_version "dev-python/bar[${PYTHON_USEDEP}]" \ |
98 |
# || has_version "dev-python/baz[${PYTHON_USEDEP}]"; } |
99 |
# } |
100 |
@@ -213,13 +238,13 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then |
101 |
# || ( |
102 |
# ( |
103 |
# dev-lang/python:3.7 |
104 |
-# dev-python/foo[python_targets_python3_7(-),-python_single_target_python3_7(-)] |
105 |
+# dev-python/foo[python_single_target_python3_7(-)] |
106 |
# || ( dev-python/bar[python_targets_python3_7(-),-python_single_target_python3_7(-)] |
107 |
# dev-python/baz[python_targets_python3_7(-),-python_single_target_python3_7(-)] ) |
108 |
# ) |
109 |
# ( |
110 |
# dev-lang/python:3.8 |
111 |
-# dev-python/foo[python_targets_python3_8(-),-python_single_target_python3_8(-)] |
112 |
+# dev-python/foo[python_single_target_python3_8(-)] |
113 |
# || ( dev-python/bar[python_targets_python3_8(-),-python_single_target_python3_8(-)] |
114 |
# dev-python/baz[python_targets_python3_8(-),-python_single_target_python3_8(-)] ) |
115 |
# ) |
116 |
@@ -234,9 +259,11 @@ python_gen_any_dep() { |
117 |
local i PYTHON_PKG_DEP out= |
118 |
for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do |
119 |
local PYTHON_USEDEP="python_targets_${i}(-),-python_single_target_${i}(-)" |
120 |
+ local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)" |
121 |
_python_export "${i}" PYTHON_PKG_DEP |
122 |
|
123 |
local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}} |
124 |
+ i_depstr=${i_depstr//\$\{PYTHON_SINGLE_USEDEP\}/${PYTHON_SINGLE_USEDEP}} |
125 |
# note: need to strip '=' slot operator for || deps |
126 |
out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}" |
127 |
done |
128 |
@@ -268,6 +295,7 @@ _python_EPYTHON_supported() { |
129 |
if python_is_installed "${i}"; then |
130 |
if declare -f python_check_deps >/dev/null; then |
131 |
local PYTHON_USEDEP="python_targets_${i}(-),-python_single_target_${i}(-)" |
132 |
+ local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)" |
133 |
python_check_deps |
134 |
return ${?} |
135 |
fi |