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 05/28] python-utils-r1.eclass: Eliminate local python_is_python3 uses
Date: Sun, 20 Jun 2021 09:57:56
Message-Id: 20210620095552.625633-6-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/28] python-r1 suite EAPI 8 support/cleanup by "Michał Górny"
1 Do not use python_is_python3 in eclass functions to ease banning it.
2 Except for wrapper setup that is still used in py2 any-r1 context,
3 we can unconditionally assume Python 3 everywhere.
4
5 Signed-off-by: Michał Górny <mgorny@g.o>
6 ---
7 eclass/python-utils-r1.eclass | 16 ++++++----------
8 1 file changed, 6 insertions(+), 10 deletions(-)
9
10 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
11 index 464e8c19b8ac..509b1b4288ac 100644
12 --- a/eclass/python-utils-r1.eclass
13 +++ b/eclass/python-utils-r1.eclass
14 @@ -191,8 +191,8 @@ _python_set_impls() {
15 # <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be
16 # either:
17 # a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
18 -# b) '-2' to indicate all Python 2 variants (= !python_is_python3)
19 -# c) '-3' to indicate all Python 3 variants (= python_is_python3)
20 +# b) '-2' to indicate all Python 2 variants
21 +# c) '-3' to indicate all Python 3 variants
22 _python_impl_matches() {
23 [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter"
24 [[ ${#} -eq 1 ]] && return 0
25 @@ -202,10 +202,9 @@ _python_impl_matches() {
26
27 for pattern; do
28 if [[ ${pattern} == -2 ]]; then
29 - python_is_python3 "${impl}" || return 0
30 + :
31 elif [[ ${pattern} == -3 ]]; then
32 - python_is_python3 "${impl}" && return 0
33 - return
34 + return 0
35 # unify value style to allow lax matching
36 elif [[ ${impl/./_} == ${pattern/./_} ]]; then
37 return 0
38 @@ -924,7 +923,7 @@ _python_wrapper_setup() {
39 _python_export "${impl}" EPYTHON PYTHON
40
41 local pyver pyother
42 - if python_is_python3; then
43 + if [[ ${EPYTHON} != python2* ]]; then
44 pyver=3
45 pyother=2
46 else
47 @@ -1101,13 +1100,10 @@ python_fix_shebang() {
48 if [[ ${i} == *python2 ]]; then
49 from=python2
50 if [[ ! ${force} ]]; then
51 - python_is_python3 "${EPYTHON}" && error=1
52 + error=1
53 fi
54 elif [[ ${i} == *python3 ]]; then
55 from=python3
56 - if [[ ! ${force} ]]; then
57 - python_is_python3 "${EPYTHON}" || error=1
58 - fi
59 else
60 from=python
61 fi
62 --
63 2.32.0