1 |
Add a QA check that reports obsolete implementation in PYTHON_COMPAT |
2 |
if ebuild has been modified in 2022 (based on copyright year). |
3 |
Requested by sam. |
4 |
|
5 |
Signed-off-by: Michał Górny <mgorny@g.o> |
6 |
--- |
7 |
eclass/python-utils-r1.eclass | 18 +++++++++++++++++- |
8 |
1 file changed, 17 insertions(+), 1 deletion(-) |
9 |
|
10 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
11 |
index 291d7ce9b771..83ac0a68da45 100644 |
12 |
--- a/eclass/python-utils-r1.eclass |
13 |
+++ b/eclass/python-utils-r1.eclass |
14 |
@@ -123,6 +123,8 @@ _python_set_impls() { |
15 |
if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then |
16 |
die 'PYTHON_COMPAT must be an array.' |
17 |
fi |
18 |
+ |
19 |
+ local obsolete=() |
20 |
if [[ ! ${PYTHON_COMPAT_NO_STRICT} ]]; then |
21 |
for i in "${PYTHON_COMPAT[@]}"; do |
22 |
# check for incorrect implementations |
23 |
@@ -130,7 +132,10 @@ _python_set_impls() { |
24 |
# please keep them in sync with _PYTHON_ALL_IMPLS |
25 |
# and _PYTHON_HISTORICAL_IMPLS |
26 |
case ${i} in |
27 |
- jython2_7|pypy|pypy1_[89]|pypy2_0|pypy3|python2_[5-7]|python3_[1-9]|python3_10) |
28 |
+ pypy3|python2_7|python3_[89]|python3_10) |
29 |
+ ;; |
30 |
+ jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[5-6]|python3_[1-7]) |
31 |
+ obsolete+=( "${i}" ) |
32 |
;; |
33 |
*) |
34 |
if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" \ |
35 |
@@ -144,6 +149,17 @@ _python_set_impls() { |
36 |
done |
37 |
fi |
38 |
|
39 |
+ if [[ -n ${obsolete[@]} && ${EBUILD_PHASE} == setup ]]; then |
40 |
+ # complain if people don't clean up old impls while touching |
41 |
+ # the ebuilds recently. use the copyright year to infer last |
42 |
+ # modification |
43 |
+ # NB: this check doesn't have to work reliably |
44 |
+ if [[ $(head -n 1 "${EBUILD}" 2>/dev/null) == *2022* ]]; then |
45 |
+ eqawarn "Please clean PYTHON_COMPAT of obsolete implementations:" |
46 |
+ eqawarn " ${obsolete[*]}" |
47 |
+ fi |
48 |
+ fi |
49 |
+ |
50 |
local supp=() unsupp=() |
51 |
|
52 |
for i in "${_PYTHON_ALL_IMPLS[@]}"; do |
53 |
-- |
54 |
2.35.1 |