1 |
On śro, 2017-05-10 at 20:53 +0200, Michał Górny wrote: |
2 |
> Allow two special values in the implementation patterns for |
3 |
> _python_impl_matches(): -2 to indicate all Python 2-compatible |
4 |
> implementations, and -3 to indicate all Python 3-compatible |
5 |
> implementations. Both of those values are implemented using |
6 |
> the python_is_python3 function. |
7 |
> |
8 |
> This is mostly meant to make it easier and more fool-proof to write |
9 |
> dependencies on backports to Python 2 which in most cases apply to PyPy2 |
10 |
> as well. |
11 |
> --- |
12 |
> eclass/python-utils-r1.eclass | 14 +++++++++++--- |
13 |
> 1 file changed, 11 insertions(+), 3 deletions(-) |
14 |
> |
15 |
> diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
16 |
> index 7efec083e35e..703246933acc 100644 |
17 |
> --- a/eclass/python-utils-r1.eclass |
18 |
> +++ b/eclass/python-utils-r1.eclass |
19 |
> @@ -156,8 +156,10 @@ _python_set_impls() { |
20 |
> # Check whether the specified <impl> matches at least one |
21 |
> # of the patterns following it. Return 0 if it does, 1 otherwise. |
22 |
> # |
23 |
> -# <impl> should be in PYTHON_COMPAT form. The patterns are fnmatch-style |
24 |
> -# patterns. |
25 |
> +# <impl> should be in PYTHON_COMPAT form. The patterns can be either: |
26 |
> +# a) fnmatch-style patterns, e.g. 'python2*', 'pypy'... |
27 |
> +# b) '-2' to indicate all Python 2 variants (= !python_is_python3) |
28 |
> +# c) '-3' to indicate all Python 3 variants (= python_is_python3) |
29 |
> _python_impl_matches() { |
30 |
> [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters" |
31 |
> |
32 |
> @@ -165,7 +167,13 @@ _python_impl_matches() { |
33 |
> shift |
34 |
> |
35 |
> for pattern; do |
36 |
> - if [[ ${impl} == ${pattern} ]]; then |
37 |
> + if [[ ${pattern} == -2 ]]; then |
38 |
> + ! python_is_python3 "${impl}" |
39 |
> + return |
40 |
> + elif [[ ${pattern} == -3 ]]; then |
41 |
> + python_is_python3 "${impl}" |
42 |
> + return |
43 |
> + elif [[ ${impl} == ${pattern} ]]; then |
44 |
> return 0 |
45 |
> fi |
46 |
> done |
47 |
|
48 |
Committed. |
49 |
|
50 |
-- |
51 |
Best regards, |
52 |
Michał Górny |