commit:     98a94936c2dead2b4a52489a37b4c43557215e1b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 20 07:44:25 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 23 21:44:07 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=98a94936

python-utils-r1.eclass: Ban py2 deps in python_gen* in EAPI 8

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 <mgorny <AT> gentoo.org>

 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 b137370f4f8..1a20a3cae99 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -189,11 +189,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
@@ -202,14 +199,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

Reply via email to