diff --git a/CHANGES.txt b/CHANGES.txt index 9656a9d..62fb096 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,11 @@ Changelog only implemented so that I can add a test using check-manifest and skip it when run from the zest.releaser hook. +- If you also have check-manifest installed, pyroma will run that as a test. + No longer do you need to call it separately! However, if Pyroma is invoked + from zest.releaser, it will not be run, because check-manifest has a separate + hook for zest.releaser, so that would run it twice. + 4.2 (2023-02-25) ---------------- diff --git a/pyroma/__init__.py b/pyroma/__init__.py index 4622c52..1bdefd9 100644 --- a/pyroma/__init__.py +++ b/pyroma/__init__.py @@ -19,7 +19,7 @@ def zester(data): from zest.releaser.utils import ask if ask("Run pyroma on the package before tagging?"): - rating = run("directory", os.path.abspath(data["workingdir"])) + rating = run("directory", os.path.abspath(data["workingdir"]), skip_tests="CheckManifest") if rating < 8: if not ask("Continue?"): sys.exit(1) diff --git a/pyroma/distributiondata.py b/pyroma/distributiondata.py index 6827fa6..fb8c666 100644 --- a/pyroma/distributiondata.py +++ b/pyroma/distributiondata.py @@ -43,7 +43,7 @@ def get_data(path): raise ValueError("Unknown file type: " + ext) projectpath = os.path.join(tempdir, basename) - data = projectdata.get_data(projectpath) + data = projectdata._get_data(projectpath) finally: shutil.rmtree(tempdir, ignore_errors=True) diff --git a/pyroma/projectdata.py b/pyroma/projectdata.py index 4039683..700dd47 100644 --- a/pyroma/projectdata.py +++ b/pyroma/projectdata.py @@ -71,6 +71,12 @@ def get_setupcfg_data(path): def get_data(path): + data = _get_data(path) + data["_path"] = path + return data + + +def _get_data(path): try: return get_build_data(path) except build.BuildException as e: diff --git a/pyroma/ratings.py b/pyroma/ratings.py index d57214c..d6630a5 100644 --- a/pyroma/ratings.py +++ b/pyroma/ratings.py @@ -15,6 +15,7 @@ # False for fail and None for not applicable (meaning it will # not be counted). import io +import os import re from collections import defaultdict @@ -507,6 +508,38 @@ def message(self): StoneAgeSetupPy(), ] +try: + import check_manifest + + class CheckManifest(BaseTest): + weight = 0 + + def test(self, data): + if "_path" not in data: + return None + + if not os.path.exists(data["_path"]): + import pdb + + pdb.set_trace() + self.weight = 200 + try: + return check_manifest.check_manifest(data["_path"]) + except check_manifest.Failure: + # Most likely this means check-manifest didn't find any + # package configuration, which is the same failure as + # MissingBuildSystem, so this is double errors, but + # it does mean your setup is completely broken, so... + return False + + def message(self): + return "Check-manifest returned errors" + + ALL_TESTS.append(CheckManifest()) + +except ImportError: + pass + def rate(data, skip_tests=None): if not data: diff --git a/pyroma/testdata/minimal/randomfile.txt b/pyroma/testdata/minimal/randomfile.txt new file mode 100644 index 0000000..8f58b0e --- /dev/null +++ b/pyroma/testdata/minimal/randomfile.txt @@ -0,0 +1 @@ +This should cause an error with check-manifest diff --git a/pyroma/tests.py b/pyroma/tests.py index f14cd9f..787d2ef 100644 --- a/pyroma/tests.py +++ b/pyroma/tests.py @@ -123,7 +123,7 @@ def test_only_config(self): self.assertEqual( rating, ( - 7, + 6, [ ( "You should specify what Python versions you support with " @@ -137,12 +137,15 @@ def test_only_config(self): ' build-backend = "setuptools.build_meta"\n\n' "In the future this will become a hard failure and your package will be " 'rated as "not cheese".', + "Check-manifest returned errors", ], ), ) def test_skip_tests(self): - rating = self._get_file_rating("only_config", skip_tests=["PythonRequiresVersion", "MissingBuildSystem"]) + rating = self._get_file_rating( + "only_config", skip_tests=["PythonRequiresVersion", "MissingBuildSystem", "CheckManifest"] + ) self.assertEqual( rating, @@ -193,6 +196,7 @@ def test_minimal(self): "Your package does neither have a license field nor any license classifiers.", "Specifying a development status in the classifiers gives users " "a hint of how stable your software is.", + "Check-manifest returned errors", ], ), ) @@ -233,7 +237,7 @@ def test_custom_test(self): self.assertEqual( rating, ( - 2, + 3, [ "The package's description should be longer than 10 characters.", "The package's long_description is quite short.", @@ -325,6 +329,7 @@ def test_complete(self): directory = resource_filename(__name__, os.path.join("testdata", "complete")) data = projectdata.get_data(directory) + del data["_path"] # This changes, so I just ignore it self.assertEqual(data, COMPLETE)