1 |
commit: 7485d43076c062e4eb637bcf2bcc10ed5623ef4a |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Nov 24 19:18:38 2022 +0000 |
4 |
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Nov 26 11:37:38 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=7485d430 |
7 |
|
8 |
PythonCheck: stop warning about eclass use on python:2.7 deps |
9 |
|
10 |
The python2_7 target support are phased out from the eclass, so stop |
11 |
warning about direct dependencies. |
12 |
|
13 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
14 |
|
15 |
src/pkgcheck/checks/python.py | 22 +++++++++++--------- |
16 |
.../python/stub/python-dep1/python-dep1-0.ebuild | 2 +- |
17 |
.../python/stub/python-dep2/python-dep2-0.ebuild | 2 +- |
18 |
.../stub/python2-locked/python2-locked-0.ebuild | 15 -------------- |
19 |
.../stub/python2-locked/python2-locked-1.ebuild | 12 ----------- |
20 |
.../stub/python2-locked/python2-locked-2.ebuild | 11 ---------- |
21 |
tests/checks/test_python.py | 24 ++++++++-------------- |
22 |
7 files changed, 22 insertions(+), 66 deletions(-) |
23 |
|
24 |
diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py |
25 |
index 918b5d5b..d8f7eb0b 100644 |
26 |
--- a/src/pkgcheck/checks/python.py |
27 |
+++ b/src/pkgcheck/checks/python.py |
28 |
@@ -17,12 +17,6 @@ from . import Check |
29 |
# NB: distutils-r1 inherits one of the first two |
30 |
ECLASSES = frozenset(['python-r1', 'python-single-r1', 'python-any-r1']) |
31 |
|
32 |
-# NB: dev-java/jython omitted as not supported by the eclasses atm |
33 |
-INTERPRETERS = frozenset([ |
34 |
- 'dev-lang/python', |
35 |
- 'dev-python/pypy3', |
36 |
-]) |
37 |
- |
38 |
IUSE_PREFIX = 'python_targets_' |
39 |
IUSE_PREFIX_S = 'python_single_target_' |
40 |
|
41 |
@@ -41,6 +35,14 @@ def get_python_eclass(pkg): |
42 |
return next(iter(eclasses)) if eclasses else None |
43 |
|
44 |
|
45 |
+def is_python_interpreter(pkg): |
46 |
+ if pkg.key == "dev-lang/python": |
47 |
+ # ignore python:2.7 deps since they are being phased out from eclass |
48 |
+ # support |
49 |
+ return pkg.slot is None or not pkg.slot.startswith("2") |
50 |
+ return pkg.key in ["dev-python/pypy3"] |
51 |
+ |
52 |
+ |
53 |
class MissingPythonEclass(results.VersionResult, results.Warning): |
54 |
"""Package depends on Python but does not use the eclasses. |
55 |
|
56 |
@@ -300,7 +302,7 @@ class PythonCheck(Check): |
57 |
flag = next(iter(x.restriction.vals)) |
58 |
if not flag.startswith(prefix): |
59 |
continue |
60 |
- if not any(y.key in INTERPRETERS for y in x if isinstance(y, atom)): |
61 |
+ if not any(is_python_interpreter(y) for y in x if isinstance(y, atom)): |
62 |
continue |
63 |
matched.add(flag[len(prefix):]) |
64 |
if matched == flags: |
65 |
@@ -436,7 +438,7 @@ class PythonCheck(Check): |
66 |
highest_found = None |
67 |
for attr in (x.lower() for x in pkg.eapi.dep_keys): |
68 |
for p in iflatten_instance(getattr(pkg, attr), atom): |
69 |
- if not p.blocks and p.key in INTERPRETERS: |
70 |
+ if not p.blocks and is_python_interpreter(p): |
71 |
highest_found = (attr, p) |
72 |
# break scanning packages, go to next attr |
73 |
break |
74 |
@@ -466,11 +468,11 @@ class PythonCheck(Check): |
75 |
else: # python-any-r1 |
76 |
for attr in ("rdepend", "pdepend"): |
77 |
for p in iflatten_instance(getattr(pkg, attr), atom): |
78 |
- if not p.blocks and p.key in INTERPRETERS: |
79 |
+ if not p.blocks and is_python_interpreter(p): |
80 |
yield PythonRuntimeDepInAnyR1(attr.upper(), str(p), pkg=pkg) |
81 |
break |
82 |
if not any( |
83 |
- not p.blocks and p.key in INTERPRETERS |
84 |
+ not p.blocks and is_python_interpreter(p) |
85 |
for attr in ("depend", "bdepend") |
86 |
for p in iflatten_instance(getattr(pkg, attr), atom) |
87 |
): |
88 |
|
89 |
diff --git a/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild b/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild |
90 |
index 55c455d9..a06d41df 100644 |
91 |
--- a/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild |
92 |
+++ b/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild |
93 |
@@ -1,5 +1,5 @@ |
94 |
EAPI=7 |
95 |
-PYTHON_COMPAT=( python2_7 python3_{7,8,9,10} ) |
96 |
+PYTHON_COMPAT=( python3_{7,8,9,10} ) |
97 |
|
98 |
inherit python-r1 |
99 |
|
100 |
|
101 |
diff --git a/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild b/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild |
102 |
index 55c455d9..a06d41df 100644 |
103 |
--- a/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild |
104 |
+++ b/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild |
105 |
@@ -1,5 +1,5 @@ |
106 |
EAPI=7 |
107 |
-PYTHON_COMPAT=( python2_7 python3_{7,8,9,10} ) |
108 |
+PYTHON_COMPAT=( python3_{7,8,9,10} ) |
109 |
|
110 |
inherit python-r1 |
111 |
|
112 |
|
113 |
diff --git a/testdata/repos/python/stub/python2-locked/python2-locked-0.ebuild b/testdata/repos/python/stub/python2-locked/python2-locked-0.ebuild |
114 |
deleted file mode 100644 |
115 |
index 2e5edb6b..00000000 |
116 |
--- a/testdata/repos/python/stub/python2-locked/python2-locked-0.ebuild |
117 |
+++ /dev/null |
118 |
@@ -1,15 +0,0 @@ |
119 |
-EAPI=7 |
120 |
-PYTHON_COMPAT=( python2_7 ) |
121 |
- |
122 |
-inherit python-r1 |
123 |
- |
124 |
-DESCRIPTION="Ebuild locked on python2" |
125 |
-HOMEPAGE="https://github.com/pkgcore/pkgcheck" |
126 |
-LICENSE="BSD" |
127 |
-SLOT="0" |
128 |
-REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
129 |
- |
130 |
-RDEPEND=" |
131 |
- ${PYTHON_DEPS} |
132 |
- stub/python-dep1[${PYTHON_USEDEP}] |
133 |
-" |
134 |
|
135 |
diff --git a/testdata/repos/python/stub/python2-locked/python2-locked-1.ebuild b/testdata/repos/python/stub/python2-locked/python2-locked-1.ebuild |
136 |
deleted file mode 100644 |
137 |
index 4766cdfe..00000000 |
138 |
--- a/testdata/repos/python/stub/python2-locked/python2-locked-1.ebuild |
139 |
+++ /dev/null |
140 |
@@ -1,12 +0,0 @@ |
141 |
-EAPI=7 |
142 |
-PYTHON_COMPAT=( python2_7 ) |
143 |
- |
144 |
-inherit python-single-r1 |
145 |
- |
146 |
-DESCRIPTION="Ebuild locked on python2" |
147 |
-HOMEPAGE="https://github.com/pkgcore/pkgcheck" |
148 |
-LICENSE="BSD" |
149 |
-SLOT="0" |
150 |
-REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
151 |
- |
152 |
-RDEPEND="${PYTHON_DEPS}" |
153 |
|
154 |
diff --git a/testdata/repos/python/stub/python2-locked/python2-locked-2.ebuild b/testdata/repos/python/stub/python2-locked/python2-locked-2.ebuild |
155 |
deleted file mode 100644 |
156 |
index fff2a3b4..00000000 |
157 |
--- a/testdata/repos/python/stub/python2-locked/python2-locked-2.ebuild |
158 |
+++ /dev/null |
159 |
@@ -1,11 +0,0 @@ |
160 |
-EAPI=7 |
161 |
-PYTHON_COMPAT=( python2_7 ) |
162 |
- |
163 |
-inherit python-any-r1 |
164 |
- |
165 |
-DESCRIPTION="Ebuild locked on python2" |
166 |
-HOMEPAGE="https://github.com/pkgcore/pkgcheck" |
167 |
-LICENSE="BSD" |
168 |
-SLOT="0" |
169 |
- |
170 |
-DEPEND="${PYTHON_DEPS}" |
171 |
|
172 |
diff --git a/tests/checks/test_python.py b/tests/checks/test_python.py |
173 |
index ec48a378..843975b5 100644 |
174 |
--- a/tests/checks/test_python.py |
175 |
+++ b/tests/checks/test_python.py |
176 |
@@ -29,9 +29,7 @@ class TestPythonCheck(misc.ReportTestCase): |
177 |
assert isinstance(r, python.MissingPythonEclass) |
178 |
assert 'missing python-any-r1 eclass usage for DEPEND="dev-lang/python"' in str(r) |
179 |
|
180 |
- assert isinstance( |
181 |
- self.assertReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:2.7')), |
182 |
- python.MissingPythonEclass) |
183 |
+ self.assertNoReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:2.7')) |
184 |
assert isinstance( |
185 |
self.assertReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:*')), |
186 |
python.MissingPythonEclass) |
187 |
@@ -53,9 +51,7 @@ class TestPythonCheck(misc.ReportTestCase): |
188 |
assert isinstance( |
189 |
self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python')), |
190 |
python.MissingPythonEclass) |
191 |
- assert isinstance( |
192 |
- self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:2.7')), |
193 |
- python.MissingPythonEclass) |
194 |
+ self.assertNoReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:2.7')) |
195 |
assert isinstance( |
196 |
self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:*')), |
197 |
python.MissingPythonEclass) |
198 |
@@ -71,19 +67,17 @@ class TestPythonCheck(misc.ReportTestCase): |
199 |
def test_missing_eclass_rdepend(self): |
200 |
self.assertNoReport( |
201 |
self.check, |
202 |
- self.mk_pkg(_eclasses_=['python-r1'], RDEPEND='dev-lang/python:2.7')) |
203 |
+ self.mk_pkg(_eclasses_=['python-r1'], RDEPEND='dev-lang/python:3.7')) |
204 |
self.assertNoReport( |
205 |
self.check, |
206 |
- self.mk_pkg(_eclasses_=['python-single-r1'], RDEPEND='dev-lang/python:2.7')) |
207 |
+ self.mk_pkg(_eclasses_=['python-single-r1'], RDEPEND='dev-lang/python:3.7')) |
208 |
self.assertNoReport(self.check, self.mk_pkg(RDEPEND='dev-foo/frobnicate')) |
209 |
|
210 |
r = self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python')) |
211 |
assert isinstance(r, python.MissingPythonEclass) |
212 |
assert 'missing python-r1 or python-single-r1 eclass' in str(r) |
213 |
|
214 |
- assert isinstance( |
215 |
- self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:2.7')), |
216 |
- python.MissingPythonEclass) |
217 |
+ self.assertNoReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:2.7')) |
218 |
assert isinstance( |
219 |
self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:=')), |
220 |
python.MissingPythonEclass) |
221 |
@@ -99,18 +93,16 @@ class TestPythonCheck(misc.ReportTestCase): |
222 |
def test_missing_eclass_pdepend(self): |
223 |
self.assertNoReport( |
224 |
self.check, |
225 |
- self.mk_pkg(_eclasses_=['python-r1'], PDEPEND='dev-lang/python:2.7')) |
226 |
+ self.mk_pkg(_eclasses_=['python-r1'], PDEPEND='dev-lang/python:3.7')) |
227 |
self.assertNoReport( |
228 |
self.check, |
229 |
- self.mk_pkg(_eclasses_=['python-single-r1'], PDEPEND='dev-lang/python:2.7')) |
230 |
+ self.mk_pkg(_eclasses_=['python-single-r1'], PDEPEND='dev-lang/python:3.7')) |
231 |
self.assertNoReport(self.check, self.mk_pkg(PDEPEND='dev-foo/frobnicate')) |
232 |
|
233 |
assert isinstance( |
234 |
self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python')), |
235 |
python.MissingPythonEclass) |
236 |
- assert isinstance( |
237 |
- self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:2.7')), |
238 |
- python.MissingPythonEclass) |
239 |
+ self.assertNoReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:2.7')) |
240 |
assert isinstance( |
241 |
self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:=')), |
242 |
python.MissingPythonEclass) |