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