Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 4/4] python-utils-r1.eclass: _python_impl_matches, handle both forms of impl
Date: Sat, 20 May 2017 08:58:59
Message-Id: 20170520085616.5602-5-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCHES] python-r1 suite: minor fixes by "Michał Górny"
1 Make the pattern matching code in _python_impl_matches() more lax,
2 allowing (accidental) mixing of PYTHON_COMPAT-style values with
3 EPYTHON-style values. This is trivial to do, and solves the problem
4 introduced by complexity-by-limitation of other eclasses -- where
5 patterns for dependency strings are using PYTHON_COMPAT syntax,
6 and patterns for python_setup are using EPYTHON syntax.
7 ---
8 eclass/python-utils-r1.eclass | 6 ++++--
9 1 file changed, 4 insertions(+), 2 deletions(-)
10
11 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
12 index 0bf7e7ec1a3e..68fb9ba2578d 100644
13 --- a/eclass/python-utils-r1.eclass
14 +++ b/eclass/python-utils-r1.eclass
15 @@ -169,7 +169,8 @@ _python_set_impls() {
16 # Check whether the specified <impl> matches at least one
17 # of the patterns following it. Return 0 if it does, 1 otherwise.
18 #
19 -# <impl> should be in PYTHON_COMPAT form. The patterns can be either:
20 +# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be
21 +# either:
22 # a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
23 # b) '-2' to indicate all Python 2 variants (= !python_is_python3)
24 # c) '-3' to indicate all Python 3 variants (= python_is_python3)
25 @@ -186,7 +187,8 @@ _python_impl_matches() {
26 elif [[ ${pattern} == -3 ]]; then
27 python_is_python3 "${impl}"
28 return
29 - elif [[ ${impl} == ${pattern} ]]; then
30 + # unify value style to allow lax matching
31 + elif [[ ${impl/./_} == ${pattern/./_} ]]; then
32 return 0
33 fi
34 done
35 --
36 2.13.0