Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 09 Feb 2022 09:39:39
Message-Id: 1644396235.ae26acc2328b9e9b832c8dee53dcc571d77a27f2.mgorny@gentoo
1 commit: ae26acc2328b9e9b832c8dee53dcc571d77a27f2
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Feb 4 21:51:22 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Feb 9 08:43:55 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae26acc2
7
8 python-utils-r1.eclass: Support matching impls by stdlib version
9
10 Update _python_impl_matches() (used to implement python_gen*,
11 python_setup) to support specifying stdlib versions ("3.8", "3.9")
12 in addition to exact implementation names. This makes handling PyPy3
13 version changes much easier when dealing with backports.
14
15 For example, if you specify "3.8", then the spec will match python3_8
16 and pypy3, for as long as we supply PyPy3.8. Once we upgrade to PyPy3.9
17 completely, it will stop matching pypy3 and we won't have to manually
18 keep updating these deps.
19
20 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
21
22 eclass/distutils-r1.eclass | 5 ++---
23 eclass/python-r1.eclass | 35 ++++++++++-------------------------
24 eclass/python-single-r1.eclass | 18 ++++++------------
25 eclass/python-utils-r1.eclass | 22 ++++++++++++++++++----
26 4 files changed, 36 insertions(+), 44 deletions(-)
27
28 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
29 index a1b840d9cc68..fd3dffeac31c 100644
30 --- a/eclass/distutils-r1.eclass
31 +++ b/eclass/distutils-r1.eclass
32 @@ -333,9 +333,8 @@ unset -f _distutils_set_globals
33 # (allowing any implementation). If multiple values are specified,
34 # implementations matching any of the patterns will be accepted.
35 #
36 -# The patterns are fnmatch-style patterns (matched via bash == operator
37 -# against PYTHON_COMPAT values). Remember to escape or quote the fnmatch
38 -# patterns to prevent accidental shell filename expansion.
39 +# For the pattern syntax, please see _python_impl_matches
40 +# in python-utils-r1.eclass.
41 #
42 # If the restriction needs to apply conditionally to a USE flag,
43 # the variable should be set conditionally as well (e.g. in an early
44
45 diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
46 index bb851e167617..bf2fd62fdcba 100644
47 --- a/eclass/python-r1.eclass
48 +++ b/eclass/python-r1.eclass
49 @@ -289,11 +289,6 @@ _python_validate_useflags() {
50 # are both in PYTHON_COMPAT and match any of the patterns passed
51 # as parameters to the function.
52 #
53 -# The patterns are fnmatch-style patterns (matched via bash
54 -# == operator against PYTHON_COMPAT values). Remember to escape
55 -# or quote the fnmatch patterns to prevent accidental shell filename
56 -# expansion.
57 -#
58 # This is an internal function used to implement python_gen_cond_dep.
59 _python_gen_usedep() {
60 debug-print-function ${FUNCNAME} "${@}"
61 @@ -322,10 +317,8 @@ _python_gen_usedep() {
62 # are both in PYTHON_COMPAT and match any of the patterns passed
63 # as parameters to the function.
64 #
65 -# The patterns are fnmatch-style patterns (matched via bash
66 -# == operator against PYTHON_COMPAT values). Remember to escape
67 -# or quote the fnmatch patterns to prevent accidental shell filename
68 -# expansion.
69 +# For the pattern syntax, please see _python_impl_matches
70 +# in python-utils-r1.eclass.
71 #
72 # Example:
73 # @CODE
74 @@ -359,10 +352,8 @@ python_gen_useflags() {
75 # of Python implementations which are both in PYTHON_COMPAT and match
76 # any of the patterns passed as the remaining parameters.
77 #
78 -# The patterns are fnmatch-style patterns (matched via bash
79 -# == operator against PYTHON_COMPAT values). Remember to escape
80 -# or quote the fnmatch patterns to prevent accidental shell filename
81 -# expansion.
82 +# For the pattern syntax, please see _python_impl_matches
83 +# in python-utils-r1.eclass.
84 #
85 # In order to enforce USE constraints on the packages, verbatim
86 # '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency
87 @@ -423,10 +414,8 @@ python_gen_cond_dep() {
88 # patterns are passed, the output dependencies will be generated only
89 # for the implementations matching them.
90 #
91 -# The patterns are fnmatch-style patterns (matched via bash
92 -# == operator against PYTHON_COMPAT values). Remember to escape
93 -# or quote the fnmatch patterns to prevent accidental shell filename
94 -# expansion.
95 +# For the pattern syntax, please see _python_impl_matches
96 +# in python-utils-r1.eclass.
97 #
98 # Use this function when you need to request different USE flags
99 # on the Python interpreter depending on package's USE flags. If you
100 @@ -479,10 +468,8 @@ python_gen_impl_dep() {
101 #
102 # Optionally, patterns may be specified to restrict the dependency to
103 # a subset of Python implementations supported by the ebuild.
104 -# The patterns are fnmatch-style patterns (matched via bash
105 -# == operator against PYTHON_COMPAT values). Remember to escape
106 -# or quote the fnmatch patterns to prevent accidental shell filename
107 -# expansion.
108 +# For the pattern syntax, please see _python_impl_matches
109 +# in python-utils-r1.eclass.
110 #
111 # This should be used along with an appropriate python_check_deps()
112 # that checks which of the any-of blocks were matched, and python_setup
113 @@ -669,10 +656,8 @@ python_foreach_impl() {
114 # The python_check_deps() function in the any-of mode needs to be
115 # accompanied by appropriate any-of dependencies.
116 #
117 -# The patterns are fnmatch-style patterns (matched via bash
118 -# == operator against PYTHON_COMPAT values). Remember to escape
119 -# or quote the fnmatch patterns to prevent accidental shell filename
120 -# expansion.
121 +# For the pattern syntax, please see _python_impl_matches
122 +# in python-utils-r1.eclass.
123 #
124 # This function needs to be used when Python is being called outside
125 # of python_foreach_impl calls (e.g. for shared processes like doc
126
127 diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
128 index 0e9a16a47d0e..998e6faad841 100644
129 --- a/eclass/python-single-r1.eclass
130 +++ b/eclass/python-single-r1.eclass
131 @@ -266,10 +266,8 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
132 # are both in PYTHON_COMPAT and match any of the patterns passed
133 # as parameters to the function.
134 #
135 -# The patterns are fnmatch-style patterns (matched via bash
136 -# == operator against PYTHON_COMPAT values). Remember to escape
137 -# or quote the fnmatch patterns to prevent accidental shell filename
138 -# expansion.
139 +# For the pattern syntax, please see _python_impl_matches
140 +# in python-utils-r1.eclass.
141 #
142 # Example:
143 # @CODE
144 @@ -303,10 +301,8 @@ python_gen_useflags() {
145 # of Python implementations which are both in PYTHON_COMPAT and match
146 # any of the patterns passed as the remaining parameters.
147 #
148 -# The patterns are fnmatch-style patterns (matched via bash
149 -# == operator against PYTHON_COMPAT values). Remember to escape
150 -# or quote the fnmatch patterns to prevent accidental shell filename
151 -# expansion.
152 +# For the pattern syntax, please see _python_impl_matches
153 +# in python-utils-r1.eclass.
154 #
155 # In order to enforce USE constraints on the packages, verbatim
156 # '${PYTHON_SINGLE_USEDEP}' and '${PYTHON_USEDEP}' (quoted!) may
157 @@ -359,10 +355,8 @@ python_gen_cond_dep() {
158 # patterns are passed, the output dependencies will be generated only
159 # for the implementations matching them.
160 #
161 -# The patterns are fnmatch-style patterns (matched via bash
162 -# == operator against PYTHON_COMPAT values). Remember to escape
163 -# or quote the fnmatch patterns to prevent accidental shell filename
164 -# expansion.
165 +# For the pattern syntax, please see _python_impl_matches
166 +# in python-utils-r1.eclass.
167 #
168 # Use this function when you need to request different USE flags
169 # on the Python interpreter depending on package's USE flags. If you
170
171 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
172 index 9dc23bf9bfb0..0703d81d9161 100644
173 --- a/eclass/python-utils-r1.eclass
174 +++ b/eclass/python-utils-r1.eclass
175 @@ -82,7 +82,11 @@ _python_verify_patterns() {
176
177 local impl pattern
178 for pattern; do
179 - [[ ${pattern} == -[23] ]] && continue
180 + case ${pattern} in
181 + -[23]|3.[89]|3.10)
182 + continue
183 + ;;
184 + esac
185
186 for impl in "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}"
187 do
188 @@ -190,12 +194,14 @@ _python_set_impls() {
189 # Matches if no patterns are provided.
190 #
191 # <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns
192 -# are fnmatch-style.
193 +# can either be fnmatch-style or stdlib versions, e.g. "3.8", "3.9".
194 +# In the latter case, pypy3 will match if there is at least one pypy3
195 +# version matching the stdlib version.
196 _python_impl_matches() {
197 [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter"
198 [[ ${#} -eq 1 ]] && return 0
199
200 - local impl=${1} pattern
201 + local impl=${1/./_} pattern
202 shift
203
204 for pattern; do
205 @@ -218,9 +224,17 @@ _python_impl_matches() {
206 fi
207 return 0
208 ;;
209 + 3.8)
210 + # the only unmasked pypy3 version is pypy3.8 atm
211 + [[ ${impl} == python${pattern/./_} || ${impl} == pypy3 ]] &&
212 + return 0
213 + ;;
214 + 3.9|3.10)
215 + [[ ${impl} == python${pattern/./_} ]] && return 0
216 + ;;
217 *)
218 # unify value style to allow lax matching
219 - [[ ${impl/./_} == ${pattern/./_} ]] && return 0
220 + [[ ${impl} == ${pattern/./_} ]] && return 0
221 ;;
222 esac
223 done