From c28f30f12cd430bcc32057361ec6fa2422c32701 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 24 Nov 2022 17:39:23 -0600 Subject: [PATCH 1/9] Add python_requires and update classifiers accordingly --- setup.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index ca446a5..89122c5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,13 +10,13 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy keywords = pypi, quality, testing author = Lennart Regebro @@ -32,6 +32,7 @@ include_package_data = True packages = find: package_dir = = . +python_requires = >=3.7 install_requires = build docutils From 6f92fefe4849def905dfec54e8923993dbb83522 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 24 Nov 2022 16:27:21 -0600 Subject: [PATCH 2/9] Use new build fn to simplify code & not require backend to be installed --- pyroma/projectdata.py | 12 ++---------- setup.cfg | 4 +--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/pyroma/projectdata.py b/pyroma/projectdata.py index da27db0..ad94ff0 100644 --- a/pyroma/projectdata.py +++ b/pyroma/projectdata.py @@ -1,13 +1,9 @@ # Extracts information from a project that has a distutils setup.py file. -import build -import email -import email.policy +import build.util import logging import os import pathlib -import pep517 import sys -import tempfile import tokenize from copy import copy from distutils import core @@ -25,11 +21,7 @@ def get_build_data(path): - with tempfile.TemporaryDirectory() as tempdir: - metadata_dir = build.ProjectBuilder(str(path), runner=pep517.quiet_subprocess_runner).prepare("wheel", tempdir) - with open(pathlib.Path(metadata_dir) / "METADATA", "rb") as metadata_file: - metadata = email.message_from_binary_file(metadata_file, policy=email.policy.compat32) - + metadata = build.util.project_wheel_metadata(path, isolated=True) if "Description" not in metadata.keys(): # Having the description as a payload tends to add two newlines, we clean that up here: long_description = metadata.get_payload().strip() + "\n" diff --git a/setup.cfg b/setup.cfg index 89122c5..571c152 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,9 +34,8 @@ package_dir = = . python_requires = >=3.7 install_requires = - build + build>=0.7.0 docutils - pep517 pygments requests setuptools>=61.0.0 @@ -51,7 +50,6 @@ test = pytest pytest-cov setuptools>=60 - flit >=3.4,<4 zest.releaser[recommended] [options.entry_points] From fb817309c14b72006e445d4b66e2aadbe7160fbc Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 24 Nov 2022 17:56:41 -0600 Subject: [PATCH 3/9] Try non-isolated 1st & fallback to isolated, and refactor build_data --- pyroma/projectdata.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pyroma/projectdata.py b/pyroma/projectdata.py index ad94ff0..20e97e2 100644 --- a/pyroma/projectdata.py +++ b/pyroma/projectdata.py @@ -1,4 +1,5 @@ # Extracts information from a project that has a distutils setup.py file. +import build import build.util import logging import os @@ -20,8 +21,20 @@ } -def get_build_data(path): - metadata = build.util.project_wheel_metadata(path, isolated=True) +def build_metadata(path, isolated=None): + # If explictly specified whether to use isolation, pass it directly + if isolated is not None: + return build.util.project_wheel_metadata(path, isolated=isolated) + + # Otherwise, try without build isolation first for efficiency + try: + return build.util.project_wheel_metadata(path, isolated=False) + # If building with build isolation fails, e.g. missing build deps, try with it + except build.BuildBackendException: + return build.util.project_wheel_metadata(path, isolated=True) + + +def map_metadata_keys(metadata): if "Description" not in metadata.keys(): # Having the description as a payload tends to add two newlines, we clean that up here: long_description = metadata.get_payload().strip() + "\n" @@ -40,6 +53,11 @@ def get_build_data(path): return data +def get_build_data(path, isolated=None): + metadata = build_metadata(path, isolated=isolated) + return map_metadata_keys(metadata) + + def get_setupcfg_data(path): # Note: By default, setup.cfg will read the pyroma.git/setup.cfg - forcing explicit setup.cfg under test's file path data = config.setupcfg.read_configuration(str(pathlib.Path(path) / "setup.cfg")) From 71fafa68d8d4b2490e7ef4fd32f0f45d67f16a50 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 24 Nov 2022 18:20:09 -0600 Subject: [PATCH 4/9] Fix bug in original get_build_data code where data could be unbound --- pyroma/projectdata.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyroma/projectdata.py b/pyroma/projectdata.py index 20e97e2..396c7d6 100644 --- a/pyroma/projectdata.py +++ b/pyroma/projectdata.py @@ -35,10 +35,11 @@ def build_metadata(path, isolated=None): def map_metadata_keys(metadata): + data = {} if "Description" not in metadata.keys(): # Having the description as a payload tends to add two newlines, we clean that up here: long_description = metadata.get_payload().strip() + "\n" - data = {"long_description": long_description} + data["long_description"] = long_description for key in set(metadata.keys()): value = metadata.get_all(key) From cdbea92fe0547f30c99590a4774145eb6d38ba98 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Fri, 2 Dec 2022 03:36:29 -0600 Subject: [PATCH 5/9] Add fallback for read_configuration on older Setuptools --- pyroma/projectdata.py | 12 +++++++----- setup.cfg | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pyroma/projectdata.py b/pyroma/projectdata.py index 396c7d6..4039683 100644 --- a/pyroma/projectdata.py +++ b/pyroma/projectdata.py @@ -8,7 +8,11 @@ import tokenize from copy import copy from distutils import core -from setuptools import config + +try: # config renamed to config.setupcfg on Setuptools >=61 adding pyproject.toml support + from setuptools.config.setupcfg import read_configuration +except ModuleNotFoundError: + from setuptools.config import read_configuration METADATA_MAP = { "summary": "description", @@ -61,7 +65,7 @@ def get_build_data(path, isolated=None): def get_setupcfg_data(path): # Note: By default, setup.cfg will read the pyroma.git/setup.cfg - forcing explicit setup.cfg under test's file path - data = config.setupcfg.read_configuration(str(pathlib.Path(path) / "setup.cfg")) + data = read_configuration(str(pathlib.Path(path) / "setup.cfg")) metadata = data["metadata"] return metadata @@ -256,9 +260,7 @@ def get_setuppy_data(path): elif os.path.isfile("setup.cfg"): try: - from setuptools import config - - data = config.read_configuration("setup.cfg") + data = read_configuration("setup.cfg") metadata = data["metadata"] metadata["_setuptools"] = True except Exception as e: diff --git a/setup.cfg b/setup.cfg index 571c152..6d659d2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ install_requires = docutils pygments requests - setuptools>=61.0.0 + setuptools>=42 trove-classifiers>=2022.6.26 wheel From f054a69d574ef642c7efd9f41585ee505c3953ff Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Mon, 5 Dec 2022 02:50:28 -0600 Subject: [PATCH 6/9] Remove mistaken pytest extras & old fetch_classifiers from setup.cfg --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 6d659d2..bd4c326 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,8 +47,6 @@ where = . [options.extras_require] test = - pytest - pytest-cov setuptools>=60 zest.releaser[recommended] @@ -69,7 +67,6 @@ testpaths = [check-manifest] ignore = .pre-commit-hooks.yaml - fetch_classifiers.py [zest.releaser] create-wheel = yes From 8d826c89e6b90b4bb7936a8aef75eb1825880f13 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sat, 17 Dec 2022 05:26:02 -0600 Subject: [PATCH 7/9] Remove redundant wheel dependency and add required packaging --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bd4c326..eb840b3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,11 +36,11 @@ python_requires = >=3.7 install_requires = build>=0.7.0 docutils + packaging pygments requests setuptools>=42 trove-classifiers>=2022.6.26 - wheel [options.packages.find] where = . From 8af0f5992c470480c4ee4ee26160f78fb85da47e Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Fri, 10 Feb 2023 00:08:27 -0600 Subject: [PATCH 8/9] Fix tests failing due to invalid versions making packages unbuildable --- pyroma/testdata/custom_test/setup.py | 2 +- pyroma/testdata/minimal/setup.py | 2 +- pyroma/tests.py | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pyroma/testdata/custom_test/setup.py b/pyroma/testdata/custom_test/setup.py index 532092d..5b7d60e 100644 --- a/pyroma/testdata/custom_test/setup.py +++ b/pyroma/testdata/custom_test/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages from setuptools.command.test import test -version = "0.0foo" +version = "0.0.1" class CustomTest(test): diff --git a/pyroma/testdata/minimal/setup.py b/pyroma/testdata/minimal/setup.py index 3e336a9..ba098ae 100644 --- a/pyroma/testdata/minimal/setup.py +++ b/pyroma/testdata/minimal/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = "0.0foo" +version = "0.0.1" setup( name="minimal", diff --git a/pyroma/tests.py b/pyroma/tests.py index d54ec3f..6c13329 100644 --- a/pyroma/tests.py +++ b/pyroma/tests.py @@ -169,7 +169,6 @@ def test_minimal(self): ( 2, [ - "The package's version number does not comply with PEP-386 or PEP-440.", "The package's description should be longer than 10 characters.", "The package's long_description is quite short.", "Your package does not have classifiers data.", @@ -228,7 +227,6 @@ def test_custom_test(self): ( 2, [ - "The package's version number does not comply with PEP-386 or PEP-440.", "The package's description should be longer than 10 characters.", "The package's long_description is quite short.", "Your package does not have classifiers data.", From fe1233fdc4325591ad17f80893452c49015c3102 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Fri, 10 Feb 2023 02:40:47 -0600 Subject: [PATCH 9/9] Add summary of changes to CHANGES.txt --- CHANGES.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ca1b74d..9bfe817 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,7 +4,18 @@ Changelog 4.2 (unreleased) ---------------- -- Nothing changed yet. +- Fall back to installing project's build backend in an isolated environment + if a compatible version isn't installed in the current env [CAM-Gerlach] + +- Fix metadata extraction failure when project ``long_description`` is included + as a header rather than a payload in the ``METADTA`` file [CAM-Gerlach] + +- Add a fallback to restore compatibility with Setuptools <61 [CAM-Gerlach] + +- Fix tests failing due to invalid versions on Setuptools >=66 [CAM-Gerlach] + +- Add ``python_requires``, update classifiers, add implicit dependencies + and remove unused deps in Pyroma's own packaging metadata [CAM-Gerlach] 4.1 (2022-11-24) @@ -27,7 +38,6 @@ Changelog - Check if author_email field contains author name [bessman] - 4.0 (2022-04-14) ----------------