From 699d7a018b641e732c8375c2538cb8b8625fc4c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Sep 2023 00:26:45 +0000 Subject: [PATCH 01/38] pre-commit: bump repositories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black-pre-commit-mirror: 23.7.0 → 23.9.1](https://github.com/psf/black-pre-commit-mirror/compare/23.7.0...23.9.1) - [github.com/astral-sh/ruff-pre-commit: v0.0.287 → v0.0.288](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.287...v0.0.288) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 59f7c344..68414bad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: hooks: - id: validate-pyproject - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black - repo: https://github.com/asottile/blacken-docs @@ -35,7 +35,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.287 + rev: v0.0.288 hooks: - id: ruff args: [--fix, --format, grouped, --show-fixes] From 74b436ea1e52756b0e3c629fd3bff3766b573f70 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 22:17:29 -0400 Subject: [PATCH 02/38] pre-commit: bump repositories (#683) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.288 → v0.0.290](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.288...v0.0.290) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 68414bad..3bceb883 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.288 + rev: v0.0.290 hooks: - id: ruff args: [--fix, --format, grouped, --show-fixes] From 203bed639dbc91bfe595dfc3f32cfaad79b1ca09 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 21:07:50 -0400 Subject: [PATCH 03/38] pre-commit: bump repositories (#686) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.290 → v0.0.291](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.290...v0.0.291) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bceb883..7500334f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.290 + rev: v0.0.291 hooks: - id: ruff args: [--fix, --format, grouped, --show-fixes] From 0d7e6cebe1b074d5578d3db03e22104961a4a803 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:05:58 -0400 Subject: [PATCH 04/38] pre-commit: bump repositories (#688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.291 → v0.0.292](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.291...v0.0.292) - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](https://github.com/codespell-project/codespell/compare/v2.2.5...v2.2.6) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7500334f..99d77bad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,12 +35,12 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.291 + rev: v0.0.292 hooks: - id: ruff args: [--fix, --format, grouped, --show-fixes] - repo: https://github.com/codespell-project/codespell - rev: "v2.2.5" + rev: "v2.2.6" hooks: - id: codespell args: ["-L", "sur"] From 71bc938b6c648210c902b74bb4e719e28da7dd92 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:57:20 -0400 Subject: [PATCH 05/38] pre-commit: bump repositories (#689) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 99d77bad..23057805 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-ast - id: check-builtin-literals From 877cb327acebddefdac97d13b389ace2d4deb00b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:55:57 -0400 Subject: [PATCH 06/38] pre-commit: bump repositories (#690) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/abravalheri/validate-pyproject: v0.14 → v0.15](https://github.com/abravalheri/validate-pyproject/compare/v0.14...v0.15) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23057805..4674ea49 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: trailing-whitespace - id: double-quote-string-fixer - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.14 + rev: v0.15 hooks: - id: validate-pyproject - repo: https://github.com/psf/black-pre-commit-mirror From 0d68abd52977190d99672870520fcc0ae648ff06 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:51:39 -0400 Subject: [PATCH 07/38] pre-commit: bump repositories (#694) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * pre-commit: bump repositories updates: - [github.com/psf/black-pre-commit-mirror: 23.9.1 → 23.10.0](https://github.com/psf/black-pre-commit-mirror/compare/23.9.1...23.10.0) - [github.com/astral-sh/ruff-pre-commit: v0.0.292 → v0.1.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.292...v0.1.1) * fix: minor ruff updates Signed-off-by: Henry Schreiner --------- Signed-off-by: Henry Schreiner Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- .pre-commit-config.yaml | 6 +++--- pyproject.toml | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4674ea49..1490437d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: hooks: - id: validate-pyproject - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black - repo: https://github.com/asottile/blacken-docs @@ -35,10 +35,10 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.1.2 hooks: - id: ruff - args: [--fix, --format, grouped, --show-fixes] + args: [--fix, --show-fixes] - repo: https://github.com/codespell-project/codespell rev: "v2.2.6" hooks: diff --git a/pyproject.toml b/pyproject.toml index 9618c396..c526e090 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -145,14 +145,15 @@ line-length = 127 skip-string-normalization = true [tool.ruff] +src = ["src"] line-length = 127 + +[tool.ruff.lint] exclude = ["tests/packages/test-bad-syntax"] -select = [ +extend-select = [ "B", # flake8-bugbear "C4", # flake8-comprehensions "C9", # mccabe - "E", # pycodestyle - "F", # pyflakes "I", # isort "PGH", # pygrep-hooks "RUF", # ruff @@ -162,15 +163,13 @@ select = [ "TRY", # tryceratops "EM", # flake8-errmsg ] -src = ["src"] -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] max-complexity = 10 -[tool.ruff.isort] +[tool.ruff.lint.isort] lines-between-types = 1 lines-after-imports = 2 -known-first-party = ["build"] [tool.check-wheel-contents] ignore = [ From 8b3155dd75ab1679eb277ccb46d265231d03636a Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 26 Oct 2023 22:10:34 +0900 Subject: [PATCH 08/38] Chore: fix Ruff `test-bad-syntax` exclusion (#697) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c526e090..fedf0bc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -146,10 +146,10 @@ skip-string-normalization = true [tool.ruff] src = ["src"] +exclude = ["tests/packages/test-bad-syntax"] line-length = 127 [tool.ruff.lint] -exclude = ["tests/packages/test-bad-syntax"] extend-select = [ "B", # flake8-bugbear "C4", # flake8-comprehensions From e3081b6a4181086da7e127121836a8e9d275ca0a Mon Sep 17 00:00:00 2001 From: Gianluca Ficarelli <26835404+GianlucaFicarelli@users.noreply.github.com> Date: Fri, 27 Oct 2023 03:53:48 +0200 Subject: [PATCH 09/38] fix: use importlib_metadata for Python < 3.10.2 (#693) * Use importlib_metadata for Python < 3.10.2 * Update tests * Apply suggestions * Trick mypy * Fix import order to work with mypy --- pyproject.toml | 2 +- src/build/_importlib.py | 7 ++++--- tests/test_util.py | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fedf0bc3..b9cc2d69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dependencies = [ "pyproject_hooks", # not actually a runtime dependency, only supplied as there is not "recommended dependency" support 'colorama; os_name == "nt"', - 'importlib-metadata >= 4.6; python_version < "3.10"', # Not required for 3.8+, but fixes a stdlib bug + 'importlib-metadata >= 4.6; python_full_version < "3.10.2"', # Not required for 3.8+, but fixes a stdlib bug 'tomli >= 1.1.0; python_version < "3.11"', ] diff --git a/src/build/_importlib.py b/src/build/_importlib.py index f95b2a69..0282729f 100644 --- a/src/build/_importlib.py +++ b/src/build/_importlib.py @@ -3,12 +3,13 @@ if sys.version_info < (3, 8): import importlib_metadata as metadata -elif sys.version_info < (3, 9, 10) or (3, 10, 0) <= sys.version_info < (3, 10, 2): +elif sys.version_info >= (3, 10, 2): + from importlib import metadata +else: try: import importlib_metadata as metadata except ModuleNotFoundError: + # helps bootstrapping when dependencies aren't installed from importlib import metadata -else: - from importlib import metadata __all__ = ['metadata'] diff --git a/tests/test_util.py b/tests/test_util.py index 74f2cf1e..8045b513 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -14,6 +14,7 @@ def test_wheel_metadata(package_test_setuptools, isolated): assert metadata['name'] == 'test-setuptools' assert metadata['version'] == '1.0.0' + assert isinstance(metadata.json, dict) @pytest.mark.network @@ -26,6 +27,7 @@ def test_wheel_metadata_isolation(package_test_flit): assert metadata['name'] == 'test_flit' assert metadata['version'] == '1.0.0' + assert isinstance(metadata.json, dict) with pytest.raises( build.BuildBackendException, @@ -42,3 +44,4 @@ def test_with_get_requires(package_test_metadata): assert metadata['name'] == 'test-metadata' assert str(metadata['version']) == '1.0.0' assert metadata['summary'] == 'hello!' + assert isinstance(metadata.json, dict) From 5a2f815c15e05f62433879fad5d21f609187bc9a Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 25 Oct 2023 21:52:32 -0400 Subject: [PATCH 10/38] fix: switch to ruff-format Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 8 ++------ pyproject.toml | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1490437d..7745309d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,20 +16,15 @@ repos: - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace - - id: double-quote-string-fixer - repo: https://github.com/abravalheri/validate-pyproject rev: v0.15 hooks: - id: validate-pyproject - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.10.1 - hooks: - - id: black - repo: https://github.com/asottile/blacken-docs rev: 1.16.0 hooks: - id: blacken-docs - additional_dependencies: [black==23.7.0] + additional_dependencies: [black==23.*] - repo: https://github.com/pre-commit/mirrors-prettier rev: "v3.0.3" hooks: @@ -39,6 +34,7 @@ repos: hooks: - id: ruff args: [--fix, --show-fixes] + - id: ruff-format - repo: https://github.com/codespell-project/codespell rev: "v2.2.6" hooks: diff --git a/pyproject.toml b/pyproject.toml index b9cc2d69..365f1414 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -149,6 +149,9 @@ src = ["src"] exclude = ["tests/packages/test-bad-syntax"] line-length = 127 +[tool.ruff.format] +quote-style = "single" + [tool.ruff.lint] extend-select = [ "B", # flake8-bugbear From 568e66dd8d3b77b54dd00acdcb937a9b094c5354 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 04:26:07 +0000 Subject: [PATCH 11/38] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/packages/test-metadata/backend.py | 4 ++-- tests/test_main.py | 4 ++-- tests/test_projectbuilder.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/packages/test-metadata/backend.py b/tests/packages/test-metadata/backend.py index 727dab9d..d1b361fb 100644 --- a/tests/packages/test-metadata/backend.py +++ b/tests/packages/test-metadata/backend.py @@ -24,12 +24,12 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None): distinfo.mkdir(parents=True, exist_ok=True) distinfo.joinpath('METADATA').write_text( textwrap.dedent( - f''' + f""" Metadata-Version: 2.2 Name: {metadata['project']['name']} Version: {metadata['project']['version']} Summary: {metadata['project']['description']} - ''' + """ ).strip() ) return distinfo.name diff --git a/tests/test_main.py b/tests/test_main.py index 361e8a13..63cbfa21 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -431,7 +431,7 @@ def test_venv_fail(monkeypatch, package_test_flit, tmp_dir, capsys): assert ( stdout - == '''\ + == """\ * Creating venv isolated environment... ERROR Failed to create venv. Maybe try installing virtualenv. Command 'test args' failed with return code 1 @@ -439,6 +439,6 @@ def test_venv_fail(monkeypatch, package_test_flit, tmp_dir, capsys): stdoutput stderr: stderror -''' +""" ) assert stderr == '' diff --git a/tests/test_projectbuilder.py b/tests/test_projectbuilder.py index d4246807..d46927b6 100644 --- a/tests/test_projectbuilder.py +++ b/tests/test_projectbuilder.py @@ -383,7 +383,7 @@ def test_build_with_dep_on_console_script(tmp_path, demo_pkg_inline, capfd, mock # to validate backend invocations contain the correct path we use an inline backend that will fail, but first # provides the PATH information (and validates shutil.which is able to discover the executable - as PEP states) toml = textwrap.dedent( - ''' + """ [build-system] requires = ["demo_pkg_inline"] build-backend = "build" @@ -392,17 +392,17 @@ def test_build_with_dep_on_console_script(tmp_path, demo_pkg_inline, capfd, mock [project] description = "Factory ⸻ A code generator 🏭" authors = [{name = "Łukasz Langa"}] - ''' + """ ) code = textwrap.dedent( - ''' + """ import os import shutil import sys print("BB " + os.environ["PATH"]) exe_at = shutil.which("demo-pkg-inline") print("BB " + exe_at) - ''' + """ ) (tmp_path / 'pyproject.toml').write_text(toml, encoding='UTF-8') (tmp_path / 'build.py').write_text(code, encoding='utf-8') From c95c2a8a6812f14648609c519f4a35cfd666e6c4 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 27 Oct 2023 14:02:59 -0400 Subject: [PATCH 12/38] chore: remove black config Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 2 +- pyproject.toml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7745309d..7b0e74b1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.2 + rev: v0.1.3 hooks: - id: ruff args: [--fix, --show-fixes] diff --git a/pyproject.toml b/pyproject.toml index 365f1414..6a665803 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,10 +140,6 @@ module = [ ] ignore_missing_imports = true -[tool.black] -line-length = 127 -skip-string-normalization = true - [tool.ruff] src = ["src"] exclude = ["tests/packages/test-bad-syntax"] From 9c5617a7192f01eb70d4c523e3941f85bfebd39c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 19:31:58 +0000 Subject: [PATCH 13/38] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/build/__main__.py | 4 ++-- src/build/_exceptions.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/build/__main__.py b/src/build/__main__.py index ba83a5e5..985caf9a 100644 --- a/src/build/__main__.py +++ b/src/build/__main__.py @@ -263,7 +263,7 @@ def main_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( description=textwrap.indent( textwrap.dedent( - ''' + """ A simple, correct Python build frontend. By default, a source distribution (sdist) is built from {srcdir} @@ -275,7 +275,7 @@ def main_parser() -> argparse.ArgumentParser: If you do this, the default behavior will be disabled, and all artifacts will be built from {srcdir} (even if you combine -w/--wheel with -s/--sdist, the wheel will be built from {srcdir}). - ''' + """ ).strip(), ' ', ), diff --git a/src/build/_exceptions.py b/src/build/_exceptions.py index 90a75b24..3d16a769 100644 --- a/src/build/_exceptions.py +++ b/src/build/_exceptions.py @@ -20,8 +20,11 @@ def __init__( self, exception: Exception, description: str | None = None, - exc_info: tuple[type[BaseException], BaseException, types.TracebackType] - | tuple[None, None, None] = (None, None, None), + exc_info: tuple[type[BaseException], BaseException, types.TracebackType] | tuple[None, None, None] = ( + None, + None, + None, + ), ) -> None: super().__init__() self.exception = exception From 96ba27a20d35cd76adb900e3f9fd34d20df684d5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 08:38:22 -0500 Subject: [PATCH 14/38] pre-commit: bump repositories (#700) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.3 → v3.1.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.3...v3.1.0) - [github.com/astral-sh/ruff-pre-commit: v0.1.3 → v0.1.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.3...v0.1.6) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b0e74b1..41235466 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,11 +26,11 @@ repos: - id: blacken-docs additional_dependencies: [black==23.*] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + rev: "v3.1.0" hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.3 + rev: v0.1.6 hooks: - id: ruff args: [--fix, --show-fixes] From de5b44b0c28c598524832dff685a98d5a5148c44 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 21 Nov 2023 08:38:41 -0500 Subject: [PATCH 15/38] chore: use exclude_also for coverage (#701) Signed-off-by: Henry Schreiner --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6a665803..8da0761a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,8 +89,7 @@ source = [ ] [tool.coverage.report] -exclude_lines = [ - '\#\s*pragma: no cover', +exclude_also = [ '^\s*raise NotImplementedError\b', "if typing.TYPE_CHECKING:", ] From ee4a8803fe3f632b8937d80dd327469dac96fdc9 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 21 Dec 2023 08:40:23 -0500 Subject: [PATCH 16/38] ci: group dependabot updates (#712) See https://github.com/scientific-python/cookie/pull/348. Signed-off-by: Henry Schreiner --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 12301490..b00bfd03 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,7 @@ updates: directory: "/" schedule: interval: "daily" + groups: + actions: + patterns: + - "*" From 9f6e34228a0da7e5ce724f400a34bc9f4e69a1ac Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 17 Jan 2024 02:44:57 -0500 Subject: [PATCH 17/38] tests: support setuptools v69.0.3+ (#722) * tests: support setuptools v69.0.3+ Signed-off-by: Henry Schreiner * tests: missed one more normalization fix Signed-off-by: Henry Schreiner * fix: add MANIFEST.in for old setuptools in tests Signed-off-by: Henry Schreiner * tests: used the wrong name Signed-off-by: Henry Schreiner --------- Signed-off-by: Henry Schreiner --- tests/packages/test-setuptools/MANIFEST.in | 1 + tests/test_projectbuilder.py | 6 ++++-- tests/test_self_packaging.py | 1 + tests/test_util.py | 6 ++++-- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tests/packages/test-setuptools/MANIFEST.in diff --git a/tests/packages/test-setuptools/MANIFEST.in b/tests/packages/test-setuptools/MANIFEST.in new file mode 100644 index 00000000..e69e3cfd --- /dev/null +++ b/tests/packages/test-setuptools/MANIFEST.in @@ -0,0 +1 @@ +include pyproject.toml setup.cfg diff --git a/tests/test_projectbuilder.py b/tests/test_projectbuilder.py index d46927b6..69914ab0 100644 --- a/tests/test_projectbuilder.py +++ b/tests/test_projectbuilder.py @@ -502,7 +502,8 @@ def test_metadata_path_no_prepare(tmp_dir, package_test_no_prepare): pathlib.Path(builder.metadata_path(tmp_dir)), ).metadata - assert metadata['name'] == 'test-no-prepare' + # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes + assert metadata['name'].replace('-', '_') == 'test_no_prepare' assert metadata['Version'] == '1.0.0' @@ -513,7 +514,8 @@ def test_metadata_path_with_prepare(tmp_dir, package_test_setuptools): pathlib.Path(builder.metadata_path(tmp_dir)), ).metadata - assert metadata['name'] == 'test-setuptools' + # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes + assert metadata['name'].replace('-', '_') == 'test_setuptools' assert metadata['Version'] == '1.0.0' diff --git a/tests/test_self_packaging.py b/tests/test_self_packaging.py index fb1d1243..3a436ef4 100644 --- a/tests/test_self_packaging.py +++ b/tests/test_self_packaging.py @@ -27,6 +27,7 @@ 'tests/constraints.txt', 'tests/packages/test-cant-build-via-sdist/some-file-that-is-needed-for-build.txt', 'tests/packages/test-no-project/empty.txt', + 'tests/packages/test-setuptools/MANIFEST.in', 'tox.ini', } diff --git a/tests/test_util.py b/tests/test_util.py index 8045b513..0ab81b84 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -12,7 +12,8 @@ def test_wheel_metadata(package_test_setuptools, isolated): metadata = build.util.project_wheel_metadata(package_test_setuptools, isolated) - assert metadata['name'] == 'test-setuptools' + # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes + assert metadata['name'].replace('-', '_') == 'test_setuptools' assert metadata['version'] == '1.0.0' assert isinstance(metadata.json, dict) @@ -41,7 +42,8 @@ def test_wheel_metadata_isolation(package_test_flit): def test_with_get_requires(package_test_metadata): metadata = build.util.project_wheel_metadata(package_test_metadata) - assert metadata['name'] == 'test-metadata' + # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes + assert metadata['name'].replace('-', '_') == 'test_metadata' assert str(metadata['version']) == '1.0.0' assert metadata['summary'] == 'hello!' assert isinstance(metadata.json, dict) From 0cb215abb47b544c796f1da7b946ff80f888ce9e Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 17 Jan 2024 03:08:27 -0500 Subject: [PATCH 18/38] docs: change URLs for build.pypa.io (#717) * docs: change URLs for build.pypa.io Signed-off-by: Henry Schreiner * Update README.md Co-authored-by: layday --------- Signed-off-by: Henry Schreiner Co-authored-by: layday --- README.md | 6 +++--- pyproject.toml | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 325a2f1e..9d0c25d8 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ [![CI test](https://github.com/pypa/build/actions/workflows/test.yml/badge.svg)](https://github.com/pypa/build/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/pypa/build/branch/main/graph/badge.svg)](https://codecov.io/gh/pypa/build) -[![Documentation Status](https://readthedocs.org/projects/pypa-build/badge/?version=latest)](https://pypa-build.readthedocs.io/en/latest/?badge=latest) +[![Documentation Status](https://readthedocs.org/projects/pypa-build/badge/?version=latest)](https://build.pypa.io/en/latest/?badge=latest) [![PyPI version](https://badge.fury.io/py/build.svg)](https://pypi.org/project/build/) [![Discord](https://img.shields.io/discord/803025117553754132?label=Discord%20chat%20%23build)](https://discord.gg/pypa) A simple, correct Python build frontend. -See the [documentation](https://pypa-build.readthedocs.io/en/latest/) for more information. +See the [documentation](https://build.pypa.io) for more information. ### Installation @@ -28,7 +28,7 @@ $ python -m build This will build the package in an isolated environment, generating a source-distribution and wheel in the directory `dist/`. -See the [documentation](https://pypa-build.readthedocs.io/en/latest/) for full information. +See the [documentation](https://build.pypa.io) for full information. ### Code of Conduct diff --git a/pyproject.toml b/pyproject.toml index 8da0761a..c20aac96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,8 +28,10 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] -urls.homepage = "https://github.com/pypa/build" -urls.changelog = "https://pypa-build.readthedocs.io/en/stable/changelog.html" +urls.changelog = "https://build.pypa.io/en/stable/changelog.html" +urls.homepage = "https://build.pypa.io" +urls.issues = "https://github.com/pypa/build/issues" +urls.source = "https://github.com/pypa/build" dependencies = [ "packaging >= 19.0", From f53d6df241b5f519da97326109c1e6834e26e36c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:40:59 +0000 Subject: [PATCH 19/38] build(deps): bump the actions group with 2 updates Bumps the actions group with 2 updates: [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) and [actions/setup-python](https://github.com/actions/setup-python). Updates `hynek/build-and-inspect-python-package` from 1 to 2 - [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases) - [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v1...v2) Updates `actions/setup-python` from 4 to 5 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: hynek/build-and-inspect-python-package dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/cd.yml | 2 +- .github/workflows/reusable-docs.yml | 2 +- .github/workflows/reusable-pytest.yml | 4 ++-- .github/workflows/reusable-type.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f4e80bc5..267abcc8 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -14,4 +14,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: hynek/build-and-inspect-python-package@v1 + - uses: hynek/build-and-inspect-python-package@v2 diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index b0216c4a..c4d39f54 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup Python 3.10 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" diff --git a/.github/workflows/reusable-pytest.yml b/.github/workflows/reusable-pytest.yml index 48eda8dd..e9736f74 100644 --- a/.github/workflows/reusable-pytest.yml +++ b/.github/workflows/reusable-pytest.yml @@ -44,7 +44,7 @@ jobs: fetch-depth: 0 - name: Setup python for test ${{ matrix.py }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} allow-prereleases: true @@ -66,7 +66,7 @@ jobs: shell: python - name: Setup python for tox - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9 diff --git a/.github/workflows/reusable-type.yml b/.github/workflows/reusable-type.yml index 76e78d7e..a3879e63 100644 --- a/.github/workflows/reusable-type.yml +++ b/.github/workflows/reusable-type.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9 From 0aced36bd88c7fbe6fc2b941d0f4a62bbbd30036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sviatoslav=20Sydorenko=20=28=D0=A1=D0=B2=D1=8F=D1=82=D0=BE?= =?UTF-8?q?=D1=81=D0=BB=D0=B0=D0=B2=20=D0=A1=D0=B8=D0=B4=D0=BE=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE=29?= Date: Wed, 17 Jan 2024 16:25:51 +0100 Subject: [PATCH 20/38] fix: stop injecting `wheel` as a build dep fallback (#716) PEP 517 doesn't mandate depending on `wheel` when a `__legacy__` setuptools fallback is used. Historically, it used to be assumed as necessary, but later it turned out to be wrong. The reason is that `setuptools`' `get_requires_for_build_wheel()` hook already injects this dependency when building wheels is requested [[1]]. It also used to have this hint in the docs, but it was corrected earlier [[2]]. This patch removes `wheel` from said `requires` list fallback. [1]: https://github.com/pypa/setuptools/blob/v40.8.0/setuptools/build_meta.py#L130 [2]: https://github.com/pypa/setuptools/pull/3056 --- CHANGELOG.rst | 9 +++++++++ src/build/__init__.py | 2 +- .../packages/test-invalid-requirements/pyproject.toml | 2 +- tests/packages/test-no-prepare/pyproject.toml | 2 +- tests/packages/test-setuptools/pyproject.toml | 2 +- tests/packages/test-typo/pyproject.toml | 2 +- tests/test_main.py | 11 +++++------ tests/test_projectbuilder.py | 2 +- 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b3210f6b..e74152ac 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,15 @@ Changelog +++++++++ + +next release +============ + +- Stopped injecting ``wheel`` as a build dependency automatically, in the + case of missing ``pyproject.toml`` -- by :user:`webknjaz`. + (:pr:`716`) + + 1.0.3 (2023-09-06) ================== diff --git a/src/build/__init__.py b/src/build/__init__.py index 34e22279..8b3b2681 100644 --- a/src/build/__init__.py +++ b/src/build/__init__.py @@ -49,7 +49,7 @@ _DEFAULT_BACKEND = { 'build-backend': 'setuptools.build_meta:__legacy__', - 'requires': ['setuptools >= 40.8.0', 'wheel'], + 'requires': ['setuptools >= 40.8.0'], } diff --git a/tests/packages/test-invalid-requirements/pyproject.toml b/tests/packages/test-invalid-requirements/pyproject.toml index 11974a0a..ec2b9200 100644 --- a/tests/packages/test-invalid-requirements/pyproject.toml +++ b/tests/packages/test-invalid-requirements/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ['setuptools >= 42.0.0', 'wheel >= 0.36.0', 'this is invalid'] +requires = ['setuptools >= 42.0.0', 'this is invalid'] build-backend = 'setuptools.build_meta' diff --git a/tests/packages/test-no-prepare/pyproject.toml b/tests/packages/test-no-prepare/pyproject.toml index c6ca5f83..2885c708 100644 --- a/tests/packages/test-no-prepare/pyproject.toml +++ b/tests/packages/test-no-prepare/pyproject.toml @@ -1,4 +1,4 @@ [build-system] build-backend = 'backend_no_prepare' backend-path = ['.'] -requires = ['setuptools >= 42.0.0', 'wheel >= 0.36.0'] +requires = ['setuptools >= 42.0.0'] diff --git a/tests/packages/test-setuptools/pyproject.toml b/tests/packages/test-setuptools/pyproject.toml index b00a27a6..7c39e0e7 100644 --- a/tests/packages/test-setuptools/pyproject.toml +++ b/tests/packages/test-setuptools/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ['setuptools >= 42.0.0', 'wheel >= 0.36.0'] +requires = ['setuptools >= 42.0.0'] build-backend = 'setuptools.build_meta' diff --git a/tests/packages/test-typo/pyproject.toml b/tests/packages/test-typo/pyproject.toml index 02d1af27..3c6a0fc5 100644 --- a/tests/packages/test-typo/pyproject.toml +++ b/tests/packages/test-typo/pyproject.toml @@ -1,3 +1,3 @@ [build_sytem] -requires = ['setuptools >= 40.8.0', 'wheel'] +requires = ['setuptools >= 40.8.0'] build-backend = 'setuptools.build_meta' diff --git a/tests/test_main.py b/tests/test_main.py index 63cbfa21..8edc3094 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -230,12 +230,12 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu [], [ '* Creating venv isolated environment...', - '* Installing packages in isolated environment... (setuptools >= 42.0.0, wheel >= 0.36.0)', + '* Installing packages in isolated environment... (setuptools >= 42.0.0)', '* Getting build dependencies for sdist...', '* Building sdist...', '* Building wheel from sdist', '* Creating venv isolated environment...', - '* Installing packages in isolated environment... (setuptools >= 42.0.0, wheel >= 0.36.0)', + '* Installing packages in isolated environment... (setuptools >= 42.0.0)', '* Getting build dependencies for wheel...', '* Installing packages in isolated environment... (wheel)', '* Building wheel...', @@ -260,7 +260,7 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu ['--wheel'], [ '* Creating venv isolated environment...', - '* Installing packages in isolated environment... (setuptools >= 42.0.0, wheel >= 0.36.0)', + '* Installing packages in isolated environment... (setuptools >= 42.0.0)', '* Getting build dependencies for wheel...', '* Installing packages in isolated environment... (wheel)', '* Building wheel...', @@ -324,7 +324,7 @@ def main_reload_styles(): 'ERROR ', [ '* Creating venv isolated environment...', - '* Installing packages in isolated environment... (setuptools >= 42.0.0, this is invalid, wheel >= 0.36.0)', + '* Installing packages in isolated environment... (setuptools >= 42.0.0, this is invalid)', '', 'Traceback (most recent call last):', ], @@ -334,8 +334,7 @@ def main_reload_styles(): '\33[91mERROR\33[0m ', [ '\33[1m* Creating venv isolated environment...\33[0m', - '\33[1m* Installing packages in isolated environment... ' - '(setuptools >= 42.0.0, this is invalid, wheel >= 0.36.0)\33[0m', + '\33[1m* Installing packages in isolated environment... (setuptools >= 42.0.0, this is invalid)\33[0m', '', '\33[2mTraceback (most recent call last):', ], diff --git a/tests/test_projectbuilder.py b/tests/test_projectbuilder.py index 69914ab0..602ca06e 100644 --- a/tests/test_projectbuilder.py +++ b/tests/test_projectbuilder.py @@ -21,7 +21,7 @@ DEFAULT_BACKEND = { 'build-backend': 'setuptools.build_meta:__legacy__', - 'requires': ['setuptools >= 40.8.0', 'wheel'], + 'requires': ['setuptools >= 40.8.0'], } From 9810faecc93bf3e9caf27a9d0ebc010c54e462d2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 11:50:30 -0500 Subject: [PATCH 21/38] pre-commit: bump repositories (#718) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * pre-commit: bump repositories updates: - [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v3.1.0...v4.0.0-alpha.8) - [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.1.13](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.6...v0.1.13) * Update .pre-commit-config.yaml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 41235466..b78704a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.6 + rev: v0.1.13 hooks: - id: ruff args: [--fix, --show-fixes] From 1eca2d31d466ac20b997ee3d1b63a10fa76561dc Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 17 Jan 2024 10:38:46 -0500 Subject: [PATCH 22/38] ci: reduce frequency Signed-off-by: Henry Schreiner --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8edc0ca8..832a95c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ on: branches: - main schedule: - - cron: "0 8 * * *" + - cron: "0 8 * * 1" workflow_dispatch: concurrency: From 8a0be701b14667d26c7cc0fd38af92ce5690c709 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 6 Sep 2023 12:55:55 -0400 Subject: [PATCH 23/38] chore: add an easy way to bump the version Signed-off-by: Henry Schreiner --- pyproject.toml | 11 +++++++++++ tox.ini | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c20aac96..51ac743d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -175,3 +175,14 @@ lines-after-imports = 2 ignore = [ "W005", # We _are_ build ] + +[tool.bumpversion] +current_version = "1.0.0" + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = 'version = "{current_version}"' + +[[tool.bumpversion.files]] +filename = "src/build/__init__.py" +search = "__version__ = '{current_version}'" diff --git a/tox.ini b/tox.ini index e841f12f..7f9c810a 100644 --- a/tox.ini +++ b/tox.ini @@ -106,3 +106,12 @@ commands = depends = path {py312, py311, py310, py39, py38, py37, pypy39, pypy38, pypy37}{, -min} + +[testenv:bump] +description = bump versions, pass major/minor/patch +skip_install = true +deps = + bump-my-version +set_env = +commands = + bump-my-version bump {posargs} From 9ff08a5180a8d68d8eaa8d0e761059e275c0e0d6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 7 Sep 2023 09:46:11 -0400 Subject: [PATCH 24/38] Address review --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 7f9c810a..ea49992a 100644 --- a/tox.ini +++ b/tox.ini @@ -111,7 +111,7 @@ depends = description = bump versions, pass major/minor/patch skip_install = true deps = - bump-my-version + bump-my-version >=0.10 set_env = commands = bump-my-version bump {posargs} From 632797c490f8750119de85e8f14f13f2a12cfc93 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:28:50 +0000 Subject: [PATCH 25/38] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ea49992a..0956c317 100644 --- a/tox.ini +++ b/tox.ini @@ -111,7 +111,7 @@ depends = description = bump versions, pass major/minor/patch skip_install = true deps = - bump-my-version >=0.10 + bump-my-version>=0.10 set_env = commands = bump-my-version bump {posargs} From 08570319af4822e5757582b1ea1c42339df040e1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 09:20:24 +0200 Subject: [PATCH 26/38] pre-commit: bump repositories (#726) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * pre-commit: bump repositories updates: - [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v3.1.0...v4.0.0-alpha.8) - [github.com/astral-sh/ruff-pre-commit: v0.1.13 → v0.1.14](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.13...v0.1.14) * Update .pre-commit-config.yaml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b78704a7..26ff80c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.13 + rev: v0.1.14 hooks: - id: ruff args: [--fix, --show-fixes] From cf86e74604f9100c9321507b18b4252c9911a31d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:29:32 +0000 Subject: [PATCH 27/38] pre-commit: bump repositories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/abravalheri/validate-pyproject: v0.15 → v0.16](https://github.com/abravalheri/validate-pyproject/compare/v0.15...v0.16) - [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v3.1.0...v4.0.0-alpha.8) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26ff80c5..10f6df94 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject - repo: https://github.com/asottile/blacken-docs @@ -26,7 +26,7 @@ repos: - id: blacken-docs additional_dependencies: [black==23.*] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.1.0" + rev: "v4.0.0-alpha.8" hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit From 26f2c5c9e576361f477c1d9b0993c3543e6645f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 08:33:45 +0000 Subject: [PATCH 28/38] build(deps): bump the actions group with 1 update Bumps the actions group with 1 update: [codecov/codecov-action](https://github.com/codecov/codecov-action). Updates `codecov/codecov-action` from 3 to 4 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3...v4) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/reusable-pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-pytest.yml b/.github/workflows/reusable-pytest.yml index e9736f74..56363853 100644 --- a/.github/workflows/reusable-pytest.yml +++ b/.github/workflows/reusable-pytest.yml @@ -91,7 +91,7 @@ jobs: if: always() run: tox -e coverage - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 if: always() env: PYTHON: ${{ matrix.python }} From 2369cc89cb84470e109e558daa39cb8e6fb2fe06 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:23:12 +0000 Subject: [PATCH 29/38] pre-commit: bump repositories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.14...v0.2.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10f6df94..5afc900b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.14 + rev: v0.2.0 hooks: - id: ruff args: [--fix, --show-fixes] From 71b37cb171119af0cf6e9b6e4feb9463e7693e93 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:47:07 +0000 Subject: [PATCH 30/38] pre-commit: bump repositories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.0 → v0.2.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.0...v0.2.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5afc900b..95d351af 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.0 + rev: v0.2.1 hooks: - id: ruff args: [--fix, --show-fixes] From e6969d10c9183925cf2c7829ef05e75b3f4477e1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:58:26 -0500 Subject: [PATCH 31/38] pre-commit: bump repositories (#734) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.1 → v0.2.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.1...v0.2.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95d351af..59e6d6f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.1 + rev: v0.2.2 hooks: - id: ruff args: [--fix, --show-fixes] From ac57b94ede8cf961b7a18f558fd9acd34243b8d2 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 19 Feb 2024 17:02:36 -0500 Subject: [PATCH 32/38] refactor: pull out pip checks (#735) Signed-off-by: Henry Schreiner --- src/build/env.py | 55 ++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/src/build/env.py b/src/build/env.py index ef8d983b..3dc909f2 100644 --- a/src/build/env.py +++ b/src/build/env.py @@ -58,6 +58,38 @@ def _should_use_virtualenv() -> bool: ) +def _minimum_pip_version() -> str: + if platform.system() == 'Darwin' and int(platform.mac_ver()[0].split('.')[0]) >= 11: + # macOS 11+ name scheme change requires 20.3. Intel macOS 11.0 can be + # told to report 10.16 for backwards compatibility; but that also fixes + # earlier versions of pip so this is only needed for 11+. + is_apple_silicon_python = platform.machine() != 'x86_64' + return '21.0.1' if is_apple_silicon_python else '20.3.0' + + # PEP-517 and manylinux1 was first implemented in 19.1 + return '19.1.0' + + +def _has_valid_pip(purelib: str) -> bool: + """ + Given a path, see if Pip is present and return True if the version is + sufficient for build, False if it is not. + """ + + import packaging.version + + if sys.version_info < (3, 8): + import importlib_metadata as metadata + else: + from importlib import metadata + + pip_distribution = next(iter(metadata.distributions(name='pip', path=[purelib]))) + + current_pip_version = packaging.version.Version(pip_distribution.version) + + return current_pip_version >= packaging.version.Version(_minimum_pip_version()) + + def _subprocess(cmd: list[str]) -> None: """Invoke subprocess and output stdout and stderr if it fails.""" try: @@ -203,13 +235,6 @@ def _create_isolated_env_venv(path: str) -> tuple[str, str]: """ import venv - import packaging.version - - if sys.version_info < (3, 8): - import importlib_metadata as metadata - else: - from importlib import metadata - symlinks = _fs_supports_symlink() try: with warnings.catch_warnings(): @@ -222,20 +247,8 @@ def _create_isolated_env_venv(path: str) -> tuple[str, str]: executable, script_dir, purelib = _find_executable_and_scripts(path) # Get the version of pip in the environment - pip_distribution = next(iter(metadata.distributions(name='pip', path=[purelib]))) - current_pip_version = packaging.version.Version(pip_distribution.version) - - if platform.system() == 'Darwin' and int(platform.mac_ver()[0].split('.')[0]) >= 11: - # macOS 11+ name scheme change requires 20.3. Intel macOS 11.0 can be told to report 10.16 for backwards - # compatibility; but that also fixes earlier versions of pip so this is only needed for 11+. - is_apple_silicon_python = platform.machine() != 'x86_64' - minimum_pip_version = '21.0.1' if is_apple_silicon_python else '20.3.0' - else: - # PEP-517 and manylinux1 was first implemented in 19.1 - minimum_pip_version = '19.1.0' - - if current_pip_version < packaging.version.Version(minimum_pip_version): - _subprocess([executable, '-m', 'pip', 'install', f'pip>={minimum_pip_version}']) + if not _has_valid_pip(purelib): + _subprocess([executable, '-m', 'pip', 'install', f'pip>={_minimum_pip_version()}']) # Avoid the setuptools from ensurepip to break the isolation _subprocess([executable, '-m', 'pip', 'uninstall', 'setuptools', '-y']) From 9ceb49db39d81d5e7efc50a371e4612323fbdb80 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:00:26 -0500 Subject: [PATCH 33/38] build(deps): bump the actions group with 1 update (#739) Bumps the actions group with 1 update: [Ana06/get-changed-files](https://github.com/ana06/get-changed-files). Updates `Ana06/get-changed-files` from 2.2.0 to 2.3.0 - [Release notes](https://github.com/ana06/get-changed-files/releases) - [Commits](https://github.com/ana06/get-changed-files/compare/v2.2.0...v2.3.0) --- updated-dependencies: - dependency-name: Ana06/get-changed-files dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/reusable-change-detection.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-change-detection.yml b/.github/workflows/reusable-change-detection.yml index fa2bfcbd..eced8417 100644 --- a/.github/workflows/reusable-change-detection.yml +++ b/.github/workflows/reusable-change-detection.yml @@ -22,7 +22,7 @@ jobs: - name: Get a list of the changed runtime-related files if: github.event_name == 'pull_request' id: changed-testable-files - uses: Ana06/get-changed-files@v2.2.0 + uses: Ana06/get-changed-files@v2.3.0 with: filter: | src/** @@ -42,7 +42,7 @@ jobs: - name: Get a list of the changed documentation-related files if: github.event_name == 'pull_request' id: changed-docs-files - uses: Ana06/get-changed-files@v2.2.0 + uses: Ana06/get-changed-files@v2.3.0 with: filter: | docs/** From af5ff536eef89e8f13b020bbb480acb8e840d280 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 19 Feb 2024 17:25:18 -0500 Subject: [PATCH 34/38] feat: use external pip if available Signed-off-by: Henry Schreiner --- src/build/env.py | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/build/env.py b/src/build/env.py index 3dc909f2..70fe8b1a 100644 --- a/src/build/env.py +++ b/src/build/env.py @@ -70,7 +70,7 @@ def _minimum_pip_version() -> str: return '19.1.0' -def _has_valid_pip(purelib: str) -> bool: +def _has_valid_pip(**distargs: str) -> bool: """ Given a path, see if Pip is present and return True if the version is sufficient for build, False if it is not. @@ -83,13 +83,29 @@ def _has_valid_pip(purelib: str) -> bool: else: from importlib import metadata - pip_distribution = next(iter(metadata.distributions(name='pip', path=[purelib]))) + pip_distribution = next(iter(metadata.distributions(name='pip', **distargs))) current_pip_version = packaging.version.Version(pip_distribution.version) return current_pip_version >= packaging.version.Version(_minimum_pip_version()) +@functools.lru_cache(maxsize=None) +def _valid_global_pip() -> bool | None: + """ + This checks for a valid global pip. Returns None if the prerequisites are + not available (Python 3.7 only) or pip is missing, False if Pip is too old, + and True if it can be used. + """ + + try: + return _has_valid_pip() + except ModuleNotFoundError: # Python 3.7 only + return None + except StopIteration: + return None + + def _subprocess(cmd: list[str]) -> None: """Invoke subprocess and output stdout and stderr if it fails.""" try: @@ -139,6 +155,12 @@ def python_executable(self) -> str: """The python executable of the isolated build environment.""" return self._python_executable + def _pip_args(self, *, isolate: bool = False) -> list[str]: + if _valid_global_pip(): + return [sys.executable, '-Im' if isolate else '-m', 'pip', '--python', self.python_executable] + else: + return [self.python_executable, '-Im' if isolate else '-m', 'pip'] + def make_extra_environ(self) -> dict[str, str]: path = os.environ.get('PATH') return {'PATH': os.pathsep.join([self._scripts_dir, path]) if path is not None else self._scripts_dir} @@ -163,9 +185,7 @@ def install(self, requirements: Collection[str]) -> None: req_file.write(os.linesep.join(requirements)) try: cmd = [ - self.python_executable, - '-Im', - 'pip', + *self._pip_args(isolate=True), 'install', '--use-pep517', '--no-warn-script-location', @@ -201,7 +221,11 @@ def _create_isolated_env_virtualenv(path: str) -> tuple[str, str]: """ import virtualenv - cmd = [str(path), '--no-setuptools', '--no-wheel', '--activators', ''] + if _valid_global_pip(): + cmd = [str(path), '--no-seed', '--activators', ''] + else: + cmd = [str(path), '--no-setuptools', '--no-wheel', '--activators', ''] + result = virtualenv.cli_run(cmd, setup_logging=False) executable = str(result.creator.exe) script_dir = str(result.creator.script_dir) @@ -240,18 +264,22 @@ def _create_isolated_env_venv(path: str) -> tuple[str, str]: with warnings.catch_warnings(): if sys.version_info[:3] == (3, 11, 0): warnings.filterwarnings('ignore', 'check_home argument is deprecated and ignored.', DeprecationWarning) - venv.EnvBuilder(with_pip=True, symlinks=symlinks).create(path) + venv.EnvBuilder(with_pip=not _valid_global_pip(), symlinks=symlinks).create(path) except subprocess.CalledProcessError as exc: raise FailedProcessError(exc, 'Failed to create venv. Maybe try installing virtualenv.') from None executable, script_dir, purelib = _find_executable_and_scripts(path) # Get the version of pip in the environment - if not _has_valid_pip(purelib): + if not _valid_global_pip() and not _has_valid_pip(path=[purelib]): _subprocess([executable, '-m', 'pip', 'install', f'pip>={_minimum_pip_version()}']) # Avoid the setuptools from ensurepip to break the isolation - _subprocess([executable, '-m', 'pip', 'uninstall', 'setuptools', '-y']) + if _valid_global_pip(): + _subprocess([sys.executable, '-m', 'pip', '--python', executable, 'uninstall', 'setuptools', '-y']) + else: + _subprocess([executable, '-m', 'pip', 'uninstall', 'setuptools', '-y']) + return executable, script_dir From aa0aa048597dbcc2cef4ece5cca393445a8ac928 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 22 Feb 2024 18:12:27 -0500 Subject: [PATCH 35/38] fix(types): make the passthrough general Signed-off-by: Henry Schreiner --- src/build/env.py | 2 +- tests/conftest.py | 5 +++++ tests/test_env.py | 3 +++ tests/test_main.py | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/build/env.py b/src/build/env.py index 70fe8b1a..cb6dbd70 100644 --- a/src/build/env.py +++ b/src/build/env.py @@ -70,7 +70,7 @@ def _minimum_pip_version() -> str: return '19.1.0' -def _has_valid_pip(**distargs: str) -> bool: +def _has_valid_pip(**distargs: object) -> bool: """ Given a path, see if Pip is present and return True if the version is sufficient for build, False if it is not. diff --git a/tests/conftest.py b/tests/conftest.py index ecc25383..8f989d68 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -65,6 +65,11 @@ def is_integration(item): return os.path.basename(item.location[0]) == 'test_integration.py' +@pytest.fixture() +def local_pip(monkeypatch): + monkeypatch.setattr(build.env, '_valid_global_pip', lambda: None) + + @pytest.fixture(scope='session', autouse=True) def ensure_syconfig_vars_created(): # the config vars are globally cached and may use get_path, make sure they are created diff --git a/tests/test_env.py b/tests/test_env.py index 41d1f478..de63c42b 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -26,6 +26,7 @@ def test_isolation(): @pytest.mark.isolated +@pytest.mark.usefixtures('local_pip') def test_isolated_environment_install(mocker): with build.env.DefaultIsolatedEnv() as env: mocker.patch('build.env._subprocess') @@ -117,6 +118,7 @@ def test_isolated_env_log(mocker, caplog, package_test_flit): @pytest.mark.isolated +@pytest.mark.usefixtures('local_pip') def test_default_pip_is_never_too_old(): with build.env.DefaultIsolatedEnv() as env: version = subprocess.check_output( @@ -130,6 +132,7 @@ def test_default_pip_is_never_too_old(): @pytest.mark.isolated @pytest.mark.parametrize('pip_version', ['20.2.0', '20.3.0', '21.0.0', '21.0.1']) @pytest.mark.parametrize('arch', ['x86_64', 'arm64']) +@pytest.mark.usefixtures('local_pip') def test_pip_needs_upgrade_mac_os_11(mocker, pip_version, arch): SimpleNamespace = collections.namedtuple('SimpleNamespace', 'version') diff --git a/tests/test_main.py b/tests/test_main.py index 8edc3094..2ca18e47 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -342,6 +342,7 @@ def main_reload_styles(): ], ids=['no-color', 'color'], ) +@pytest.mark.usefixtures('local_pip') def test_output_env_subprocess_error( mocker, monkeypatch, From 894998a5fbb08ae169baf1f413f9fc5d1e1c3d3f Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 26 Feb 2024 10:52:33 -0500 Subject: [PATCH 36/38] chore: address feedback Signed-off-by: Henry Schreiner --- src/build/env.py | 40 +++++++++++++++++++--------------------- tests/test_env.py | 3 +-- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/build/env.py b/src/build/env.py index cb6dbd70..95ba9d15 100644 --- a/src/build/env.py +++ b/src/build/env.py @@ -73,17 +73,20 @@ def _minimum_pip_version() -> str: def _has_valid_pip(**distargs: object) -> bool: """ Given a path, see if Pip is present and return True if the version is - sufficient for build, False if it is not. + sufficient for build, False if it is not. ModuleNotFoundError is thrown if + pip is not present. """ import packaging.version - if sys.version_info < (3, 8): - import importlib_metadata as metadata - else: - from importlib import metadata + from ._importlib import metadata + + name = 'pip' - pip_distribution = next(iter(metadata.distributions(name='pip', **distargs))) + try: + pip_distribution = next(iter(metadata.distributions(name=name, **distargs))) + except StopIteration: + raise ModuleNotFoundError(name) from None current_pip_version = packaging.version.Version(pip_distribution.version) @@ -93,16 +96,13 @@ def _has_valid_pip(**distargs: object) -> bool: @functools.lru_cache(maxsize=None) def _valid_global_pip() -> bool | None: """ - This checks for a valid global pip. Returns None if the prerequisites are - not available (Python 3.7 only) or pip is missing, False if Pip is too old, - and True if it can be used. + This checks for a valid global pip. Returns None if pip is missing, False + if Pip is too old, and True if it can be used. """ try: return _has_valid_pip() - except ModuleNotFoundError: # Python 3.7 only - return None - except StopIteration: + except ModuleNotFoundError: return None @@ -155,11 +155,11 @@ def python_executable(self) -> str: """The python executable of the isolated build environment.""" return self._python_executable - def _pip_args(self, *, isolate: bool = False) -> list[str]: + def _pip_args(self) -> list[str]: if _valid_global_pip(): - return [sys.executable, '-Im' if isolate else '-m', 'pip', '--python', self.python_executable] + return [sys.executable, '-Im', 'pip', '--python', self.python_executable] else: - return [self.python_executable, '-Im' if isolate else '-m', 'pip'] + return [self.python_executable, '-Im', 'pip'] def make_extra_environ(self) -> dict[str, str]: path = os.environ.get('PATH') @@ -185,7 +185,7 @@ def install(self, requirements: Collection[str]) -> None: req_file.write(os.linesep.join(requirements)) try: cmd = [ - *self._pip_args(isolate=True), + *self._pip_args(), 'install', '--use-pep517', '--no-warn-script-location', @@ -222,9 +222,9 @@ def _create_isolated_env_virtualenv(path: str) -> tuple[str, str]: import virtualenv if _valid_global_pip(): - cmd = [str(path), '--no-seed', '--activators', ''] + cmd = [path, '--no-seed', '--activators', ''] else: - cmd = [str(path), '--no-setuptools', '--no-wheel', '--activators', ''] + cmd = [path, '--no-setuptools', '--no-wheel', '--activators', ''] result = virtualenv.cli_run(cmd, setup_logging=False) executable = str(result.creator.exe) @@ -275,9 +275,7 @@ def _create_isolated_env_venv(path: str) -> tuple[str, str]: _subprocess([executable, '-m', 'pip', 'install', f'pip>={_minimum_pip_version()}']) # Avoid the setuptools from ensurepip to break the isolation - if _valid_global_pip(): - _subprocess([sys.executable, '-m', 'pip', '--python', executable, 'uninstall', 'setuptools', '-y']) - else: + if not _valid_global_pip(): _subprocess([executable, '-m', 'pip', 'uninstall', 'setuptools', '-y']) return executable, script_dir diff --git a/tests/test_env.py b/tests/test_env.py index de63c42b..feaf042a 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -140,8 +140,7 @@ def test_pip_needs_upgrade_mac_os_11(mocker, pip_version, arch): mocker.patch('platform.system', return_value='Darwin') mocker.patch('platform.machine', return_value=arch) mocker.patch('platform.mac_ver', return_value=('11.0', ('', '', ''), '')) - metadata_name = 'importlib_metadata' if sys.version_info < (3, 8) else 'importlib.metadata' - mocker.patch(metadata_name + '.distributions', return_value=(SimpleNamespace(version=pip_version),)) + mocker.patch('build._importlib.metadata.distributions', return_value=(SimpleNamespace(version=pip_version),)) min_version = Version('20.3' if arch == 'x86_64' else '21.0.1') with build.env.DefaultIsolatedEnv(): From 42231a70ca203272e884f0612acef3fa2ef149dd Mon Sep 17 00:00:00 2001 From: layday Date: Mon, 26 Feb 2024 22:55:03 +0200 Subject: [PATCH 37/38] compat: create separate importlib, tarfile and tomllib shims --- src/build/__init__.py | 7 +--- src/build/__main__.py | 4 +-- src/build/_compat/__init__.py | 0 .../{_importlib.py => _compat/importlib.py} | 7 +++- src/build/_compat/tarfile.py | 32 +++++++++++++++++++ src/build/_compat/tomllib.py | 16 ++++++++++ src/build/_util.py | 31 ++---------------- src/build/env.py | 4 +-- src/build/util.py | 8 ++--- tests/test_env.py | 2 +- tests/test_projectbuilder.py | 2 +- tests/test_self_packaging.py | 6 +++- 12 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 src/build/_compat/__init__.py rename src/build/{_importlib.py => _compat/importlib.py} (84%) create mode 100644 src/build/_compat/tarfile.py create mode 100644 src/build/_compat/tomllib.py diff --git a/src/build/__init__.py b/src/build/__init__.py index 8b3b2681..c92daba7 100644 --- a/src/build/__init__.py +++ b/src/build/__init__.py @@ -24,6 +24,7 @@ import pyproject_hooks from . import env +from ._compat import tomllib from ._exceptions import ( BuildBackendException, BuildException, @@ -34,12 +35,6 @@ from ._util import check_dependency, parse_wheel_filename -if sys.version_info >= (3, 11): - import tomllib -else: - import tomli as tomllib - - RunnerType = Callable[[Sequence[str], Optional[str], Optional[Mapping[str, str]]], None] ConfigSettingsType = Mapping[str, Union[str, Sequence[str]]] PathType = Union[str, 'os.PathLike[str]'] diff --git a/src/build/__main__.py b/src/build/__main__.py index 985caf9a..03c3dcd8 100644 --- a/src/build/__main__.py +++ b/src/build/__main__.py @@ -230,7 +230,7 @@ def build_package_via_sdist( :param isolation: Isolate the build in a separate environment :param skip_dependency_check: Do not perform the dependency check """ - from ._util import TarFile + from ._compat import tarfile if 'sdist' in distributions: msg = 'Only binary distributions are allowed but sdist was specified' @@ -243,7 +243,7 @@ def build_package_via_sdist( built: list[str] = [] if distributions: # extract sdist - with TarFile.open(sdist) as t: + with tarfile.TarFile.open(sdist) as t: t.extractall(sdist_out) try: _ProjectBuilder.log(f'Building {_natural_language_list(distributions)} from sdist') diff --git a/src/build/_compat/__init__.py b/src/build/_compat/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/build/_importlib.py b/src/build/_compat/importlib.py similarity index 84% rename from src/build/_importlib.py rename to src/build/_compat/importlib.py index 0282729f..7487ddfd 100644 --- a/src/build/_importlib.py +++ b/src/build/_compat/importlib.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys @@ -12,4 +14,7 @@ # helps bootstrapping when dependencies aren't installed from importlib import metadata -__all__ = ['metadata'] + +__all__ = [ + 'metadata', +] diff --git a/src/build/_compat/tarfile.py b/src/build/_compat/tarfile.py new file mode 100644 index 00000000..2984a497 --- /dev/null +++ b/src/build/_compat/tarfile.py @@ -0,0 +1,32 @@ +from __future__ import annotations + +import sys +import tarfile +import typing + + +if typing.TYPE_CHECKING: + TarFile = tarfile.TarFile + +else: + # Per https://peps.python.org/pep-0706/, the "data" filter will become + # the default in Python 3.14. The first series of releases with the filter + # had a broken filter that could not process symlinks correctly. + if ( + (3, 8, 18) <= sys.version_info < (3, 9) + or (3, 9, 18) <= sys.version_info < (3, 10) + or (3, 10, 13) <= sys.version_info < (3, 11) + or (3, 11, 5) <= sys.version_info < (3, 12) + or (3, 12) <= sys.version_info < (3, 14) + ): + + class TarFile(tarfile.TarFile): + extraction_filter = staticmethod(tarfile.data_filter) + + else: + TarFile = tarfile.TarFile + + +__all__ = [ + 'TarFile', +] diff --git a/src/build/_compat/tomllib.py b/src/build/_compat/tomllib.py new file mode 100644 index 00000000..51191efe --- /dev/null +++ b/src/build/_compat/tomllib.py @@ -0,0 +1,16 @@ +from __future__ import annotations + +import sys + + +if sys.version_info >= (3, 11): + from tomllib import TOMLDecodeError, load, loads +else: + from tomli import TOMLDecodeError, load, loads + + +__all__ = [ + 'TOMLDecodeError', + 'load', + 'loads', +] diff --git a/src/build/_util.py b/src/build/_util.py index 691e15a7..a57c41eb 100644 --- a/src/build/_util.py +++ b/src/build/_util.py @@ -1,9 +1,6 @@ from __future__ import annotations import re -import sys -import tarfile -import typing from collections.abc import Iterator, Set @@ -27,7 +24,7 @@ def check_dependency( """ import packaging.requirements - from ._importlib import metadata + from ._compat import importlib req = packaging.requirements.Requirement(req_string) normalised_req_string = str(req) @@ -48,8 +45,8 @@ def check_dependency( return try: - dist = metadata.distribution(req.name) - except metadata.PackageNotFoundError: + dist = importlib.metadata.distribution(req.name) + except importlib.metadata.PackageNotFoundError: # dependency is not installed in the environment. yield (*ancestral_req_strings, normalised_req_string) else: @@ -64,25 +61,3 @@ def check_dependency( def parse_wheel_filename(filename: str) -> re.Match[str] | None: return _WHEEL_FILENAME_REGEX.match(filename) - - -if typing.TYPE_CHECKING: - TarFile = tarfile.TarFile - -else: - # Per https://peps.python.org/pep-0706/, the "data" filter will become - # the default in Python 3.14. The first series of releases with the filter - # had a broken filter that could not process symlinks correctly. - if ( - (3, 8, 18) <= sys.version_info < (3, 9) - or (3, 9, 18) <= sys.version_info < (3, 10) - or (3, 10, 13) <= sys.version_info < (3, 11) - or (3, 11, 5) <= sys.version_info < (3, 12) - or (3, 12) <= sys.version_info < (3, 14) - ): - - class TarFile(tarfile.TarFile): - extraction_filter = staticmethod(tarfile.data_filter) - - else: - TarFile = tarfile.TarFile diff --git a/src/build/env.py b/src/build/env.py index 95ba9d15..5cb7a3ae 100644 --- a/src/build/env.py +++ b/src/build/env.py @@ -79,12 +79,12 @@ def _has_valid_pip(**distargs: object) -> bool: import packaging.version - from ._importlib import metadata + from ._compat import importlib name = 'pip' try: - pip_distribution = next(iter(metadata.distributions(name=name, **distargs))) + pip_distribution = next(iter(importlib.metadata.distributions(name=name, **distargs))) except StopIteration: raise ModuleNotFoundError(name) from None diff --git a/src/build/util.py b/src/build/util.py index 9f204b85..671c1c62 100644 --- a/src/build/util.py +++ b/src/build/util.py @@ -8,14 +8,14 @@ import pyproject_hooks from . import PathType, ProjectBuilder, RunnerType -from ._importlib import metadata +from ._compat import importlib from .env import DefaultIsolatedEnv -def _project_wheel_metadata(builder: ProjectBuilder) -> metadata.PackageMetadata: +def _project_wheel_metadata(builder: ProjectBuilder) -> importlib.metadata.PackageMetadata: with tempfile.TemporaryDirectory() as tmpdir: path = pathlib.Path(builder.metadata_path(tmpdir)) - return metadata.PathDistribution(path).metadata + return importlib.metadata.PathDistribution(path).metadata def project_wheel_metadata( @@ -23,7 +23,7 @@ def project_wheel_metadata( isolated: bool = True, *, runner: RunnerType = pyproject_hooks.quiet_subprocess_runner, -) -> metadata.PackageMetadata: +) -> importlib.metadata.PackageMetadata: """ Return the wheel metadata for a project. diff --git a/tests/test_env.py b/tests/test_env.py index feaf042a..379d8e57 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -140,7 +140,7 @@ def test_pip_needs_upgrade_mac_os_11(mocker, pip_version, arch): mocker.patch('platform.system', return_value='Darwin') mocker.patch('platform.machine', return_value=arch) mocker.patch('platform.mac_ver', return_value=('11.0', ('', '', ''), '')) - mocker.patch('build._importlib.metadata.distributions', return_value=(SimpleNamespace(version=pip_version),)) + mocker.patch('build._compat.importlib.metadata.distributions', return_value=(SimpleNamespace(version=pip_version),)) min_version = Version('20.3' if arch == 'x86_64' else '21.0.1') with build.env.DefaultIsolatedEnv(): diff --git a/tests/test_projectbuilder.py b/tests/test_projectbuilder.py index 602ca06e..cccb3852 100644 --- a/tests/test_projectbuilder.py +++ b/tests/test_projectbuilder.py @@ -13,7 +13,7 @@ import build -from build import _importlib +from build._compat import importlib as _importlib build_open_owner = 'builtins' diff --git a/tests/test_self_packaging.py b/tests/test_self_packaging.py index 3a436ef4..9d515e5d 100644 --- a/tests/test_self_packaging.py +++ b/tests/test_self_packaging.py @@ -34,6 +34,7 @@ sdist_patterns = { 'docs/*.rst', 'src/build/*.py', + 'src/build/_compat/*.py', 'tests/*.py', 'tests/packages/*/*.py', 'tests/packages/*/*/*.py', @@ -46,8 +47,11 @@ wheel_files = { 'build/__init__.py', 'build/__main__.py', + 'build/_compat/__init__.py', + 'build/_compat/importlib.py', + 'build/_compat/tarfile.py', + 'build/_compat/tomllib.py', 'build/_exceptions.py', - 'build/_importlib.py', 'build/_util.py', 'build/env.py', 'build/py.typed', From da0697318dfc36afa8ae57f814c15cc39d225758 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 29 Feb 2024 11:45:51 -0500 Subject: [PATCH 38/38] chore: prepare for 1.1.0 (#744) * chore: update changelog Signed-off-by: Henry Schreiner * chore: bump version to 1.1.0 Signed-off-by: Henry Schreiner --------- Signed-off-by: Henry Schreiner --- CHANGELOG.rst | 14 +++++++++++++- pyproject.toml | 2 +- src/build/__init__.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e74152ac..6136a6ee 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,9 +6,21 @@ Changelog next release ============ +Python 3.7 (past EoL) support will be removed. + +1.1.0 (2024-02-29) +================== + +- Use external pip if available instead of installing, speeds up environment + setup with virtualenv slightly and venv significantly. + (PR :pr:`736`) - Stopped injecting ``wheel`` as a build dependency automatically, in the case of missing ``pyproject.toml`` -- by :user:`webknjaz`. - (:pr:`716`) + (PR :pr:`716`) +- Use ``importlib_metadata`` on Python <3.10.2 for bugfixes not present in + those CPython standard libraries (not required when bootstrapping) -- by + :user:`GianlucaFicarelli`. + (PR :pr:`693`, fixes issue :issue:`692`) 1.0.3 (2023-09-06) diff --git a/pyproject.toml b/pyproject.toml index 51ac743d..403ef5e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "build" -version = "1.0.3" +version = "1.1.0" description = "A simple, correct Python build frontend" readme = "README.md" requires-python = ">= 3.7" diff --git a/src/build/__init__.py b/src/build/__init__.py index c92daba7..3c70aa71 100644 --- a/src/build/__init__.py +++ b/src/build/__init__.py @@ -7,7 +7,7 @@ from __future__ import annotations -__version__ = '1.0.3' +__version__ = '1.1.0' import contextlib import difflib