Ban using -2 or python2* as an argument to python_gen_cond_dep and other functions using _python_impl_matches, in order to force cleaning up old entries, in EAPI 8.
Signed-off-by: Michał Górny <[email protected]> --- eclass/python-utils-r1.eclass | 39 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 509b1b4288ac..1ff794ede1de 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -188,11 +188,8 @@ _python_set_impls() { # of the patterns following it. Return 0 if it does, 1 otherwise. # Matches if no patterns are provided. # -# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be -# either: -# a) fnmatch-style patterns, e.g. 'python2*', 'pypy'... -# b) '-2' to indicate all Python 2 variants -# c) '-3' to indicate all Python 3 variants +# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns +# are fnmatch-style. _python_impl_matches() { [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter" [[ ${#} -eq 1 ]] && return 0 @@ -201,14 +198,30 @@ _python_impl_matches() { shift for pattern; do - if [[ ${pattern} == -2 ]]; then - : - elif [[ ${pattern} == -3 ]]; then - return 0 - # unify value style to allow lax matching - elif [[ ${impl/./_} == ${pattern/./_} ]]; then - return 0 - fi + case ${pattern} in + -2|python2*|pypy) + if [[ ${EAPI} != [67] ]]; then + eerror + eerror "Python 2 is no longer supported in Gentoo, please remove Python 2" + eerror "${FUNCNAME[1]} calls." + die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}" + fi + ;; + -3) + # NB: "python3*" is fine, as "not pypy3" + if [[ ${EAPI} != [67] ]]; then + eerror + eerror "Python 2 is no longer supported in Gentoo, please remove Python 2" + eerror "${FUNCNAME[1]} calls." + die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}" + fi + return 0 + ;; + *) + # unify value style to allow lax matching + [[ ${impl/./_} == ${pattern/./_} ]] && return 0 + ;; + esac done return 1 -- 2.32.0
