commit: e8d16ecb9765c32694b7a518381aee94ef5d9108 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Sat Mar 4 09:20:28 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Sun Mar 5 17:13:22 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=e8d16ecb
checks: git: add PythonPEP517WithoutRevbump Warn when DISTUTILS_USE_PEP517 is added or removed from an ebuild without a new revision. This is important because PEP517 affects a package's installed files anyway and it's important to ensure that dependencies work correctly against it, but also because e.g. config files or other data files might either now be installed to the wrong location or not installed at all. Developers must inspect the image before/after (e.g. using iwdevtools) to avoid issues. Fixes: https://github.com/pkgcore/pkgcheck/issues/498 Signed-off-by: Sam James <sam <AT> gentoo.org> Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcheck/checks/git.py | 28 ++++++++++++++++++++++++++++ tests/checks/test_git.py | 19 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/pkgcheck/checks/git.py b/src/pkgcheck/checks/git.py index 8b272531..22780cbe 100644 --- a/src/pkgcheck/checks/git.py +++ b/src/pkgcheck/checks/git.py @@ -171,6 +171,18 @@ class MissingMove(results.PackageResult, results.Error): return f"renamed package: {self.old} -> {self.new}" +class PythonPEP517WithoutRevbump(results.PackageResult, results.Warning): + """Package has started/stopped using DISTUTILS_USE_PEP517 without revbump. + + The package has started or stopped using DISTUTILS_USE_PEP517 without + a new revision. PEP517 affects the files installed by a package + and might lead to some files missing. + + """ + + desc = "changed DISTUTILS_USE_PEP517 without new revision" + + class SrcUriChecksumChange(results.PackageResult, results.Error): """SRC_URI changing checksum without distfile rename.""" @@ -265,9 +277,12 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): MissingMove, SrcUriChecksumChange, SuspiciousSrcUriChange, + PythonPEP517WithoutRevbump, ] ) + python_pep517_regex = re.compile("^DISTUTILS_USE_PEP517=") + # package categories that are committed with stable keywords allowed_direct_stable = frozenset(["acct-user", "acct-group"]) @@ -364,6 +379,19 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): if pkg not in added and old_pkg.rdepend != new_pkg.rdepend: yield RdependChange(pkg=new_pkg) + if "distutils-r1" in new_pkg.inherited: + + def found_pep517_lines(cmp_pkg): + return any( + self.python_pep517_regex.match(line) for line in cmp_pkg.ebuild.text_fileobj() + ) + + found_old_pep517_line = found_pep517_lines(old_pkg) + found_new_pep517_line = found_pep517_lines(new_pkg) + + if found_old_pep517_line ^ found_new_pep517_line: + yield PythonPEP517WithoutRevbump(pkg=new_pkg) + old_slot, new_slot = old_pkg.slot, new_pkg.slot if old_slot != new_slot: slotmoves = ( diff --git a/tests/checks/test_git.py b/tests/checks/test_git.py index 57fc28ac..5deaad71 100644 --- a/tests/checks/test_git.py +++ b/tests/checks/test_git.py @@ -675,6 +675,25 @@ class TestGitPkgCommitsCheck(ReportTestCase): r = self.assertReport(self.check, self.source) assert r == git_mod.SrcUriChecksumChange(distfile[1], pkg=CP("cat/pkg")) + def test_python_pep517_change(self): + with open(pjoin(self.parent_git_repo.path, "eclass/distutils-r1.eclass"), "w") as f: + f.write("# Copyright 1999-2019 Gentoo Authors") + self.parent_git_repo.add_all("eclass: add distutils-r1") + + # add pkgs to parent repo + self.parent_repo.create_ebuild("newcat/newpkg-1", data="inherit distutils-r1") + self.parent_git_repo.add_all("newcat/newpkg: initial import") + # pull changes to child repo + self.child_git_repo.run(["git", "pull", "origin", "main"]) + # change an existing ebuild to have DISTUTILS_USE_PEP517 with no revbump + with open(pjoin(self.child_git_repo.path, "newcat/newpkg/newpkg-1.ebuild"), "a") as f: + f.write("\nDISTUTILS_USE_PEP517=setuptools\n") + self.child_git_repo.add_all("newcat/newpkg: use PEP517") + self.init_check() + r = self.assertReport(self.check, self.source) + expected = git_mod.PythonPEP517WithoutRevbump(pkg=CPV("newcat/newpkg-1")) + assert r == expected + def test_src_uri_change(self): distfile = [ "DIST",
