public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: testdata/repos/python/stub/python-dep1/, testdata/repos/python/stub/python-dep2/, ...
Date: Sat, 26 Nov 2022 11:47:32 +0000 (UTC)	[thread overview]
Message-ID: <1669462658.7485d43076c062e4eb637bcf2bcc10ed5623ef4a.arthurzam@gentoo> (raw)

commit:     7485d43076c062e4eb637bcf2bcc10ed5623ef4a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 24 19:18:38 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 26 11:37:38 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=7485d430

PythonCheck: stop warning about eclass use on python:2.7 deps

The python2_7 target support are phased out from the eclass, so stop
warning about direct dependencies.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 src/pkgcheck/checks/python.py                      | 22 +++++++++++---------
 .../python/stub/python-dep1/python-dep1-0.ebuild   |  2 +-
 .../python/stub/python-dep2/python-dep2-0.ebuild   |  2 +-
 .../stub/python2-locked/python2-locked-0.ebuild    | 15 --------------
 .../stub/python2-locked/python2-locked-1.ebuild    | 12 -----------
 .../stub/python2-locked/python2-locked-2.ebuild    | 11 ----------
 tests/checks/test_python.py                        | 24 ++++++++--------------
 7 files changed, 22 insertions(+), 66 deletions(-)

diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index 918b5d5b..d8f7eb0b 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -17,12 +17,6 @@ from . import Check
 # NB: distutils-r1 inherits one of the first two
 ECLASSES = frozenset(['python-r1', 'python-single-r1', 'python-any-r1'])
 
-# NB: dev-java/jython omitted as not supported by the eclasses atm
-INTERPRETERS = frozenset([
-    'dev-lang/python',
-    'dev-python/pypy3',
-])
-
 IUSE_PREFIX = 'python_targets_'
 IUSE_PREFIX_S = 'python_single_target_'
 
@@ -41,6 +35,14 @@ def get_python_eclass(pkg):
     return next(iter(eclasses)) if eclasses else None
 
 
+def is_python_interpreter(pkg):
+    if pkg.key == "dev-lang/python":
+        # ignore python:2.7 deps since they are being phased out from eclass
+        # support
+        return pkg.slot is None or not pkg.slot.startswith("2")
+    return pkg.key in ["dev-python/pypy3"]
+
+
 class MissingPythonEclass(results.VersionResult, results.Warning):
     """Package depends on Python but does not use the eclasses.
 
@@ -300,7 +302,7 @@ class PythonCheck(Check):
                 flag = next(iter(x.restriction.vals))
                 if not flag.startswith(prefix):
                     continue
-                if not any(y.key in INTERPRETERS for y in x if isinstance(y, atom)):
+                if not any(is_python_interpreter(y) for y in x if isinstance(y, atom)):
                     continue
                 matched.add(flag[len(prefix):])
             if matched == flags:
@@ -436,7 +438,7 @@ class PythonCheck(Check):
             highest_found = None
             for attr in (x.lower() for x in pkg.eapi.dep_keys):
                 for p in iflatten_instance(getattr(pkg, attr), atom):
-                    if not p.blocks and p.key in INTERPRETERS:
+                    if not p.blocks and is_python_interpreter(p):
                         highest_found = (attr, p)
                         # break scanning packages, go to next attr
                         break
@@ -466,11 +468,11 @@ class PythonCheck(Check):
         else:  # python-any-r1
             for attr in ("rdepend", "pdepend"):
                 for p in iflatten_instance(getattr(pkg, attr), atom):
-                    if not p.blocks and p.key in INTERPRETERS:
+                    if not p.blocks and is_python_interpreter(p):
                         yield PythonRuntimeDepInAnyR1(attr.upper(), str(p), pkg=pkg)
                         break
             if not any(
-                not p.blocks and p.key in INTERPRETERS
+                not p.blocks and is_python_interpreter(p)
                 for attr in ("depend", "bdepend")
                 for p in iflatten_instance(getattr(pkg, attr), atom)
             ):

diff --git a/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild b/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild
index 55c455d9..a06d41df 100644
--- a/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild
+++ b/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild
@@ -1,5 +1,5 @@
 EAPI=7
-PYTHON_COMPAT=( python2_7 python3_{7,8,9,10} )
+PYTHON_COMPAT=( python3_{7,8,9,10} )
 
 inherit python-r1
 

diff --git a/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild b/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild
index 55c455d9..a06d41df 100644
--- a/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild
+++ b/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild
@@ -1,5 +1,5 @@
 EAPI=7
-PYTHON_COMPAT=( python2_7 python3_{7,8,9,10} )
+PYTHON_COMPAT=( python3_{7,8,9,10} )
 
 inherit python-r1
 

diff --git a/testdata/repos/python/stub/python2-locked/python2-locked-0.ebuild b/testdata/repos/python/stub/python2-locked/python2-locked-0.ebuild
deleted file mode 100644
index 2e5edb6b..00000000
--- a/testdata/repos/python/stub/python2-locked/python2-locked-0.ebuild
+++ /dev/null
@@ -1,15 +0,0 @@
-EAPI=7
-PYTHON_COMPAT=( python2_7 )
-
-inherit python-r1
-
-DESCRIPTION="Ebuild locked on python2"
-HOMEPAGE="https://github.com/pkgcore/pkgcheck"
-LICENSE="BSD"
-SLOT="0"
-REQUIRED_USE="${PYTHON_REQUIRED_USE}"
-
-RDEPEND="
-	${PYTHON_DEPS}
-	stub/python-dep1[${PYTHON_USEDEP}]
-"

diff --git a/testdata/repos/python/stub/python2-locked/python2-locked-1.ebuild b/testdata/repos/python/stub/python2-locked/python2-locked-1.ebuild
deleted file mode 100644
index 4766cdfe..00000000
--- a/testdata/repos/python/stub/python2-locked/python2-locked-1.ebuild
+++ /dev/null
@@ -1,12 +0,0 @@
-EAPI=7
-PYTHON_COMPAT=( python2_7 )
-
-inherit python-single-r1
-
-DESCRIPTION="Ebuild locked on python2"
-HOMEPAGE="https://github.com/pkgcore/pkgcheck"
-LICENSE="BSD"
-SLOT="0"
-REQUIRED_USE="${PYTHON_REQUIRED_USE}"
-
-RDEPEND="${PYTHON_DEPS}"

diff --git a/testdata/repos/python/stub/python2-locked/python2-locked-2.ebuild b/testdata/repos/python/stub/python2-locked/python2-locked-2.ebuild
deleted file mode 100644
index fff2a3b4..00000000
--- a/testdata/repos/python/stub/python2-locked/python2-locked-2.ebuild
+++ /dev/null
@@ -1,11 +0,0 @@
-EAPI=7
-PYTHON_COMPAT=( python2_7 )
-
-inherit python-any-r1
-
-DESCRIPTION="Ebuild locked on python2"
-HOMEPAGE="https://github.com/pkgcore/pkgcheck"
-LICENSE="BSD"
-SLOT="0"
-
-DEPEND="${PYTHON_DEPS}"

diff --git a/tests/checks/test_python.py b/tests/checks/test_python.py
index ec48a378..843975b5 100644
--- a/tests/checks/test_python.py
+++ b/tests/checks/test_python.py
@@ -29,9 +29,7 @@ class TestPythonCheck(misc.ReportTestCase):
         assert isinstance(r, python.MissingPythonEclass)
         assert 'missing python-any-r1 eclass usage for DEPEND="dev-lang/python"' in str(r)
 
-        assert isinstance(
-            self.assertReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:2.7')),
-            python.MissingPythonEclass)
+        self.assertNoReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:2.7'))
         assert isinstance(
             self.assertReport(self.check, self.mk_pkg(DEPEND='dev-lang/python:*')),
             python.MissingPythonEclass)
@@ -53,9 +51,7 @@ class TestPythonCheck(misc.ReportTestCase):
         assert isinstance(
             self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python')),
             python.MissingPythonEclass)
-        assert isinstance(
-            self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:2.7')),
-            python.MissingPythonEclass)
+        self.assertNoReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:2.7'))
         assert isinstance(
             self.assertReport(self.check, self.mk_pkg(BDEPEND='dev-lang/python:*')),
             python.MissingPythonEclass)
@@ -71,19 +67,17 @@ class TestPythonCheck(misc.ReportTestCase):
     def test_missing_eclass_rdepend(self):
         self.assertNoReport(
             self.check,
-            self.mk_pkg(_eclasses_=['python-r1'], RDEPEND='dev-lang/python:2.7'))
+            self.mk_pkg(_eclasses_=['python-r1'], RDEPEND='dev-lang/python:3.7'))
         self.assertNoReport(
             self.check,
-            self.mk_pkg(_eclasses_=['python-single-r1'], RDEPEND='dev-lang/python:2.7'))
+            self.mk_pkg(_eclasses_=['python-single-r1'], RDEPEND='dev-lang/python:3.7'))
         self.assertNoReport(self.check, self.mk_pkg(RDEPEND='dev-foo/frobnicate'))
 
         r = self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python'))
         assert isinstance(r, python.MissingPythonEclass)
         assert 'missing python-r1 or python-single-r1 eclass' in str(r)
 
-        assert isinstance(
-            self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:2.7')),
-            python.MissingPythonEclass)
+        self.assertNoReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:2.7'))
         assert isinstance(
             self.assertReport(self.check, self.mk_pkg(RDEPEND='dev-lang/python:=')),
             python.MissingPythonEclass)
@@ -99,18 +93,16 @@ class TestPythonCheck(misc.ReportTestCase):
     def test_missing_eclass_pdepend(self):
         self.assertNoReport(
             self.check,
-            self.mk_pkg(_eclasses_=['python-r1'], PDEPEND='dev-lang/python:2.7'))
+            self.mk_pkg(_eclasses_=['python-r1'], PDEPEND='dev-lang/python:3.7'))
         self.assertNoReport(
             self.check,
-            self.mk_pkg(_eclasses_=['python-single-r1'], PDEPEND='dev-lang/python:2.7'))
+            self.mk_pkg(_eclasses_=['python-single-r1'], PDEPEND='dev-lang/python:3.7'))
         self.assertNoReport(self.check, self.mk_pkg(PDEPEND='dev-foo/frobnicate'))
 
         assert isinstance(
             self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python')),
             python.MissingPythonEclass)
-        assert isinstance(
-            self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:2.7')),
-            python.MissingPythonEclass)
+        self.assertNoReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:2.7'))
         assert isinstance(
             self.assertReport(self.check, self.mk_pkg(PDEPEND='dev-lang/python:=')),
             python.MissingPythonEclass)


                 reply	other threads:[~2022-11-26 11:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1669462658.7485d43076c062e4eb637bcf2bcc10ed5623ef4a.arthurzam@gentoo \
    --to=arthurzam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox