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, 23 Jun 2021 21:44:36
Message-Id: 1624484647.98a94936c2dead2b4a52489a37b4c43557215e1b.mgorny@gentoo
1 commit: 98a94936c2dead2b4a52489a37b4c43557215e1b
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 20 07:44:25 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 23 21:44:07 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=98a94936
7
8 python-utils-r1.eclass: Ban py2 deps in python_gen* in EAPI 8
9
10 Ban using -2 or python2* as an argument to python_gen_cond_dep and other
11 functions using _python_impl_matches, in order to force cleaning up old
12 entries, in EAPI 8.
13
14 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
15
16 eclass/python-utils-r1.eclass | 39 ++++++++++++++++++++++++++-------------
17 1 file changed, 26 insertions(+), 13 deletions(-)
18
19 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
20 index b137370f4f8..1a20a3cae99 100644
21 --- a/eclass/python-utils-r1.eclass
22 +++ b/eclass/python-utils-r1.eclass
23 @@ -189,11 +189,8 @@ _python_set_impls() {
24 # of the patterns following it. Return 0 if it does, 1 otherwise.
25 # Matches if no patterns are provided.
26 #
27 -# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be
28 -# either:
29 -# a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
30 -# b) '-2' to indicate all Python 2 variants
31 -# c) '-3' to indicate all Python 3 variants
32 +# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns
33 +# are fnmatch-style.
34 _python_impl_matches() {
35 [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter"
36 [[ ${#} -eq 1 ]] && return 0
37 @@ -202,14 +199,30 @@ _python_impl_matches() {
38 shift
39
40 for pattern; do
41 - if [[ ${pattern} == -2 ]]; then
42 - :
43 - elif [[ ${pattern} == -3 ]]; then
44 - return 0
45 - # unify value style to allow lax matching
46 - elif [[ ${impl/./_} == ${pattern/./_} ]]; then
47 - return 0
48 - fi
49 + case ${pattern} in
50 + -2|python2*|pypy)
51 + if [[ ${EAPI} != [67] ]]; then
52 + eerror
53 + eerror "Python 2 is no longer supported in Gentoo, please remove Python 2"
54 + eerror "${FUNCNAME[1]} calls."
55 + die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}"
56 + fi
57 + ;;
58 + -3)
59 + # NB: "python3*" is fine, as "not pypy3"
60 + if [[ ${EAPI} != [67] ]]; then
61 + eerror
62 + eerror "Python 2 is no longer supported in Gentoo, please remove Python 2"
63 + eerror "${FUNCNAME[1]} calls."
64 + die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}"
65 + fi
66 + return 0
67 + ;;
68 + *)
69 + # unify value style to allow lax matching
70 + [[ ${impl/./_} == ${pattern/./_} ]] && return 0
71 + ;;
72 + esac
73 done
74
75 return 1