Skip to content

Commit e8d16ec

Browse files
thesamesamarthurzam
authored andcommitted
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: #498 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent bf68177 commit e8d16ec

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

src/pkgcheck/checks/git.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ def desc(self):
171171
return f"renamed package: {self.old} -> {self.new}"
172172

173173

174+
class PythonPEP517WithoutRevbump(results.PackageResult, results.Warning):
175+
"""Package has started/stopped using DISTUTILS_USE_PEP517 without revbump.
176+
177+
The package has started or stopped using DISTUTILS_USE_PEP517 without
178+
a new revision. PEP517 affects the files installed by a package
179+
and might lead to some files missing.
180+
181+
"""
182+
183+
desc = "changed DISTUTILS_USE_PEP517 without new revision"
184+
185+
174186
class SrcUriChecksumChange(results.PackageResult, results.Error):
175187
"""SRC_URI changing checksum without distfile rename."""
176188

@@ -265,9 +277,12 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck):
265277
MissingMove,
266278
SrcUriChecksumChange,
267279
SuspiciousSrcUriChange,
280+
PythonPEP517WithoutRevbump,
268281
]
269282
)
270283

284+
python_pep517_regex = re.compile("^DISTUTILS_USE_PEP517=")
285+
271286
# package categories that are committed with stable keywords
272287
allowed_direct_stable = frozenset(["acct-user", "acct-group"])
273288

@@ -364,6 +379,19 @@ def modified_checks(self, pkgs, added):
364379
if pkg not in added and old_pkg.rdepend != new_pkg.rdepend:
365380
yield RdependChange(pkg=new_pkg)
366381

382+
if "distutils-r1" in new_pkg.inherited:
383+
384+
def found_pep517_lines(cmp_pkg):
385+
return any(
386+
self.python_pep517_regex.match(line) for line in cmp_pkg.ebuild.text_fileobj()
387+
)
388+
389+
found_old_pep517_line = found_pep517_lines(old_pkg)
390+
found_new_pep517_line = found_pep517_lines(new_pkg)
391+
392+
if found_old_pep517_line ^ found_new_pep517_line:
393+
yield PythonPEP517WithoutRevbump(pkg=new_pkg)
394+
367395
old_slot, new_slot = old_pkg.slot, new_pkg.slot
368396
if old_slot != new_slot:
369397
slotmoves = (

tests/checks/test_git.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,25 @@ def test_checksum_change(self):
675675
r = self.assertReport(self.check, self.source)
676676
assert r == git_mod.SrcUriChecksumChange(distfile[1], pkg=CP("cat/pkg"))
677677

678+
def test_python_pep517_change(self):
679+
with open(pjoin(self.parent_git_repo.path, "eclass/distutils-r1.eclass"), "w") as f:
680+
f.write("# Copyright 1999-2019 Gentoo Authors")
681+
self.parent_git_repo.add_all("eclass: add distutils-r1")
682+
683+
# add pkgs to parent repo
684+
self.parent_repo.create_ebuild("newcat/newpkg-1", data="inherit distutils-r1")
685+
self.parent_git_repo.add_all("newcat/newpkg: initial import")
686+
# pull changes to child repo
687+
self.child_git_repo.run(["git", "pull", "origin", "main"])
688+
# change an existing ebuild to have DISTUTILS_USE_PEP517 with no revbump
689+
with open(pjoin(self.child_git_repo.path, "newcat/newpkg/newpkg-1.ebuild"), "a") as f:
690+
f.write("\nDISTUTILS_USE_PEP517=setuptools\n")
691+
self.child_git_repo.add_all("newcat/newpkg: use PEP517")
692+
self.init_check()
693+
r = self.assertReport(self.check, self.source)
694+
expected = git_mod.PythonPEP517WithoutRevbump(pkg=CPV("newcat/newpkg-1"))
695+
assert r == expected
696+
678697
def test_src_uri_change(self):
679698
distfile = [
680699
"DIST",

0 commit comments

Comments
 (0)