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 4/4] python-r1.eclass: Support PYTHON_SINGLE_USEDEP in any-dep API
Date: Thu, 17 Dec 2020 21:25:55
Message-Id: 20201217212450.317226-4-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 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/python-r1.eclass | 40 +++++++++++++++++++++++++++++++++-------
4 1 file changed, 33 insertions(+), 7 deletions(-)
5
6 diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
7 index e7a660219c17..5cae020c6d90 100644
8 --- a/eclass/python-r1.eclass
9 +++ b/eclass/python-r1.eclass
10 @@ -152,6 +152,28 @@ fi
11 # python_targets_python2_7(-)?,python_targets_python3_4(-)?
12 # @CODE
13
14 +# @ECLASS-VARIABLE: PYTHON_SINGLE_USEDEP
15 +# @OUTPUT_VARIABLE
16 +# @DESCRIPTION:
17 +# An eclass-generated USE-dependency string for the currently tested
18 +# implementation. It is set locally for python_check_deps() call.
19 +#
20 +# The generated USE-flag list is compatible with packages using
21 +# python-single-r1 eclass. For python-r1 dependencies,
22 +# use PYTHON_USEDEP.
23 +#
24 +# Example use:
25 +# @CODE
26 +# python_check_deps() {
27 +# has_version "dev-python/bar[${PYTHON_SINGLE_USEDEP}]"
28 +# }
29 +# @CODE
30 +#
31 +# Example value:
32 +# @CODE
33 +# python_single_target_python3_7(-)
34 +# @CODE
35 +
36 # @ECLASS-VARIABLE: PYTHON_REQUIRED_USE
37 # @OUTPUT_VARIABLE
38 # @DESCRIPTION:
39 @@ -507,9 +529,10 @@ python_gen_impl_dep() {
40 # Generate an any-of dependency that enforces a version match between
41 # the Python interpreter and Python packages. <dependency-block> needs
42 # to list one or more dependencies with verbatim '${PYTHON_USEDEP}'
43 -# references (quoted!) that will get expanded inside the function.
44 -# Optionally, patterns may be specified to restrict the dependency
45 -# to a subset of Python implementations supported by the ebuild.
46 +# or '${PYTHON_SINGLE_USEDEP}' references (quoted!) that will get
47 +# expanded inside the function. Optionally, patterns may be specified
48 +# to restrict the dependency to a subset of Python implementations
49 +# supported by the ebuild.
50 #
51 # The patterns can be either fnmatch-style patterns (matched via bash
52 # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
53 @@ -524,12 +547,12 @@ python_gen_impl_dep() {
54 # Example use:
55 # @CODE
56 # DEPEND="$(python_gen_any_dep '
57 -# dev-python/foo[${PYTHON_USEDEP}]
58 +# dev-python/foo[${PYTHON_SINGLE_USEDEP}]
59 # || ( dev-python/bar[${PYTHON_USEDEP}]
60 # dev-python/baz[${PYTHON_USEDEP}] )' -2)"
61 #
62 # python_check_deps() {
63 -# has_version "dev-python/foo[${PYTHON_USEDEP}]" \
64 +# has_version "dev-python/foo[${PYTHON_SINGLE_USEDEP}]" \
65 # && { has_version "dev-python/bar[${PYTHON_USEDEP}]" \
66 # || has_version "dev-python/baz[${PYTHON_USEDEP}]"; }
67 # }
68 @@ -548,13 +571,13 @@ python_gen_impl_dep() {
69 # || (
70 # (
71 # dev-lang/python:3.7
72 -# dev-python/foo[python_targets_python3_7(-),-python_single_target_python3_7(-)]
73 +# dev-python/foo[python_single_target_python3_7(-)]
74 # || ( dev-python/bar[python_targets_python3_7(-),-python_single_target_python3_7(-)]
75 # dev-python/baz[python_targets_python3_7(-),-python_single_target_python3_7(-)] )
76 # )
77 # (
78 # dev-lang/python:3.8
79 -# dev-python/foo[python_targets_python3_8(-),-python_single_target_python3_8(-)]
80 +# dev-python/foo[python_single_target_python3_8(-)]
81 # || ( dev-python/bar[python_targets_python3_8(-),-python_single_target_python3_8(-)]
82 # dev-python/baz[python_targets_python3_8(-),-python_single_target_python3_8(-)] )
83 # )
84 @@ -572,9 +595,11 @@ python_gen_any_dep() {
85 for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
86 if _python_impl_matches "${i}" "${@}"; then
87 local PYTHON_USEDEP="python_targets_${i}(-),-python_single_target_${i}(-)"
88 + local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
89 _python_export "${i}" PYTHON_PKG_DEP
90
91 local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}}
92 + i_depstr=${i_depstr//\$\{PYTHON_SINGLE_USEDEP\}/${PYTHON_SINGLE_USEDEP}}
93 # note: need to strip '=' slot operator for || deps
94 out="( ${PYTHON_PKG_DEP/:0=/:0} ${i_depstr} ) ${out}"
95 fi
96 @@ -780,6 +805,7 @@ python_setup() {
97 python_is_installed "${impl}" || continue
98 # then run python_check_deps
99 local PYTHON_USEDEP="python_targets_${impl}(-),-python_single_target_${impl}(-)"
100 + local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)"
101 python_check_deps || continue
102 fi
103
104 --
105 2.29.2