diff options
author | Michał Górny <mgorny@gentoo.org> | 2022-02-04 22:51:22 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2022-02-09 09:43:55 +0100 |
commit | ae26acc2328b9e9b832c8dee53dcc571d77a27f2 (patch) | |
tree | 82e2678e0dc85f0dd8f62dc340522684a472d84a /eclass/python-utils-r1.eclass | |
parent | python-utils-r1.eclass: Add status messages to python_optimize (diff) | |
download | gentoo-ae26acc2328b9e9b832c8dee53dcc571d77a27f2.tar.gz gentoo-ae26acc2328b9e9b832c8dee53dcc571d77a27f2.tar.bz2 gentoo-ae26acc2328b9e9b832c8dee53dcc571d77a27f2.zip |
python-utils-r1.eclass: Support matching impls by stdlib version
Update _python_impl_matches() (used to implement python_gen*,
python_setup) to support specifying stdlib versions ("3.8", "3.9")
in addition to exact implementation names. This makes handling PyPy3
version changes much easier when dealing with backports.
For example, if you specify "3.8", then the spec will match python3_8
and pypy3, for as long as we supply PyPy3.8. Once we upgrade to PyPy3.9
completely, it will stop matching pypy3 and we won't have to manually
keep updating these deps.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r-- | eclass/python-utils-r1.eclass | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 9dc23bf9bfb0..0703d81d9161 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -82,7 +82,11 @@ _python_verify_patterns() { local impl pattern for pattern; do - [[ ${pattern} == -[23] ]] && continue + case ${pattern} in + -[23]|3.[89]|3.10) + continue + ;; + esac for impl in "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}" do @@ -190,12 +194,14 @@ _python_set_impls() { # Matches if no patterns are provided. # # <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns -# are fnmatch-style. +# can either be fnmatch-style or stdlib versions, e.g. "3.8", "3.9". +# In the latter case, pypy3 will match if there is at least one pypy3 +# version matching the stdlib version. _python_impl_matches() { [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter" [[ ${#} -eq 1 ]] && return 0 - local impl=${1} pattern + local impl=${1/./_} pattern shift for pattern; do @@ -218,9 +224,17 @@ _python_impl_matches() { fi return 0 ;; + 3.8) + # the only unmasked pypy3 version is pypy3.8 atm + [[ ${impl} == python${pattern/./_} || ${impl} == pypy3 ]] && + return 0 + ;; + 3.9|3.10) + [[ ${impl} == python${pattern/./_} ]] && return 0 + ;; *) # unify value style to allow lax matching - [[ ${impl/./_} == ${pattern/./_} ]] && return 0 + [[ ${impl} == ${pattern/./_} ]] && return 0 ;; esac done |