diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 165725c5..eca2cb05 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,9 @@ Changelog Unreleased ========== +- Replace ``pep517`` dependency with ``pyproject_hooks``, + into which ``pep517`` has been renamed + (`PR #539`_, Fixes `#529`_) - Change build backend from ``setuptools`` to ``flit`` (`PR #470`_, Fixes `#394`_) - Dropped support for Python 3.6 (`PR #532`_) @@ -13,7 +16,8 @@ Unreleased .. _PR #470: https://github.com/pypa/build/pull/470 .. _PR #532: https://github.com/pypa/build/pull/532 .. _#394: https://github.com/pypa/build/issues/394 - +.. _PR #539: https://github.com/pypa/build/pull/539 +.. _#529: https://github.com/pypa/build/issues/529 0.9.0 (2022-10-27) ================== diff --git a/README.md b/README.md index 0932fd1f..a6569875 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![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&style=flat-square)](https://discord.gg/pypa) -A simple, correct PEP 517 build frontend. +A simple, correct Python build frontend. See the [documentation](https://pypa-build.readthedocs.io/en/latest/) for more information. diff --git a/pyproject.toml b/pyproject.toml index 903d9dc9..9ed7dee6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi" [project] name = "build" version = "0.9.0" -description = "A simple, correct PEP 517 build frontend" +description = "A simple, correct Python build frontend" readme = "README.md" requires-python = ">= 3.7" license.file = "LICENSE" @@ -32,12 +32,12 @@ urls.changelog = "https://pypa-build.readthedocs.io/en/stable/changelog.html" dependencies = [ "packaging >= 19.0", - "pep517 >= 0.9.1", + "pyproject_hooks", # not actually a runtime dependency, only supplied as there is not "recommended dependency" support 'colorama; os_name == "nt"', 'importlib-metadata >= 0.22; python_version < "3.8"', # toml can be used instead -- in case it makes bootstrapping easier - 'tomli >= 1.0.0; python_version < "3.11"', + 'tomli >= 1.1.0; python_version < "3.11"', ] [project.optional-dependencies] @@ -124,7 +124,7 @@ enable_error_code = ["ignore-without-code", "truthy-bool", "redundant-expr"] [[tool.mypy.overrides]] module = [ "colorama", # Optional dependency - "pep517.*", # Untyped + "pyproject_hooks.*", # Untyped "virtualenv", # Optional dependency ] ignore_missing_imports = true diff --git a/src/build/__init__.py b/src/build/__init__.py index aa51d1ec..6288385b 100644 --- a/src/build/__init__.py +++ b/src/build/__init__.py @@ -25,7 +25,7 @@ from collections.abc import Iterator, Set from typing import Any, Callable, Mapping, MutableMapping, Optional, Sequence, Tuple, Type, Union -import pep517.wrappers +import pyproject_hooks TOMLDecodeError: type[Exception] @@ -243,7 +243,7 @@ def __init__( srcdir: PathType, python_executable: str = sys.executable, scripts_dir: str | None = None, - runner: RunnerType = pep517.wrappers.default_subprocess_runner, + runner: RunnerType = pyproject_hooks.default_subprocess_runner, ) -> None: """ :param srcdir: The source directory @@ -282,7 +282,7 @@ def __init__( self._backend = self._build_system['build-backend'] self._scripts_dir = scripts_dir self._hook_runner = runner - self._hook = pep517.wrappers.Pep517HookCaller( + self._hook = pyproject_hooks.BuildBackendHookCaller( self.srcdir, self._backend, backend_path=self._build_system.get('backend-path'), @@ -388,7 +388,7 @@ def prepare( _allow_fallback=False, ) except BuildBackendException as exception: - if isinstance(exception.exception, pep517.wrappers.HookMissing): + if isinstance(exception.exception, pyproject_hooks.HookMissing): return None raise @@ -464,7 +464,7 @@ def _call_backend( def _handle_backend(self, hook: str) -> Iterator[None]: try: yield - except pep517.wrappers.BackendUnavailable as exception: + except pyproject_hooks.BackendUnavailable as exception: raise BuildBackendException( # noqa: B904 # use raise from exception, f"Backend '{self._backend}' is not available.", diff --git a/src/build/__main__.py b/src/build/__main__.py index 72dbc65a..2d65720e 100644 --- a/src/build/__main__.py +++ b/src/build/__main__.py @@ -260,7 +260,7 @@ def main_parser() -> argparse.ArgumentParser: description=textwrap.indent( textwrap.dedent( ''' - A simple, correct PEP 517 build frontend. + A simple, correct Python build frontend. By default, a source distribution (sdist) is built from {srcdir} and a binary distribution (wheel) is built from the sdist. diff --git a/src/build/util.py b/src/build/util.py index 96753933..110cfc8b 100644 --- a/src/build/util.py +++ b/src/build/util.py @@ -7,7 +7,7 @@ import sys import tempfile -import pep517 +import pyproject_hooks import build import build.env @@ -43,7 +43,7 @@ def project_wheel_metadata( """ builder = build.ProjectBuilder( os.fspath(srcdir), - runner=pep517.quiet_subprocess_runner, + runner=pyproject_hooks.quiet_subprocess_runner, ) if not isolated: diff --git a/tests/constraints.txt b/tests/constraints.txt index b073bd97..104ef6a6 100644 --- a/tests/constraints.txt +++ b/tests/constraints.txt @@ -1,9 +1,9 @@ importlib-metadata==0.22 packaging==19.0 -pep517==0.9.1 +pyproject_hooks==1.0 setuptools==42.0.0; python_version < "3.10" setuptools==56.0.0; python_version >= "3.10" toml==0.10.0 -tomli==1.0.0 +tomli==1.1.0 virtualenv==20.0.35 wheel==0.36.0 diff --git a/tests/test_projectbuilder.py b/tests/test_projectbuilder.py index f25078a7..0382dcd7 100644 --- a/tests/test_projectbuilder.py +++ b/tests/test_projectbuilder.py @@ -8,7 +8,7 @@ import sys import textwrap -import pep517.wrappers +import pyproject_hooks import pytest import build @@ -185,25 +185,25 @@ def test_bad_project(package_test_no_project): def test_init(mocker, package_test_flit, package_legacy, test_no_permission, package_test_bad_syntax): - mocker.patch('pep517.wrappers.Pep517HookCaller') + mocker.patch('pyproject_hooks.BuildBackendHookCaller') # correct flit pyproject.toml builder = build.ProjectBuilder(package_test_flit) - pep517.wrappers.Pep517HookCaller.assert_called_with( + pyproject_hooks.BuildBackendHookCaller.assert_called_with( package_test_flit, 'flit_core.buildapi', backend_path=None, python_executable=sys.executable, runner=builder._runner ) - pep517.wrappers.Pep517HookCaller.reset_mock() + pyproject_hooks.BuildBackendHookCaller.reset_mock() # custom python builder = build.ProjectBuilder(package_test_flit, python_executable='some-python') - pep517.wrappers.Pep517HookCaller.assert_called_with( + pyproject_hooks.BuildBackendHookCaller.assert_called_with( package_test_flit, 'flit_core.buildapi', backend_path=None, python_executable='some-python', runner=builder._runner ) - pep517.wrappers.Pep517HookCaller.reset_mock() + pyproject_hooks.BuildBackendHookCaller.reset_mock() # FileNotFoundError builder = build.ProjectBuilder(package_legacy) - pep517.wrappers.Pep517HookCaller.assert_called_with( + pyproject_hooks.BuildBackendHookCaller.assert_called_with( package_legacy, 'setuptools.build_meta:__legacy__', backend_path=None, @@ -263,15 +263,15 @@ def test_build_missing_backend(packages_path, distribution, tmpdir): def test_check_dependencies(mocker, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller.get_requires_for_build_sdist') - mocker.patch('pep517.wrappers.Pep517HookCaller.get_requires_for_build_wheel') + mocker.patch('pyproject_hooks.BuildBackendHookCaller.get_requires_for_build_sdist') + mocker.patch('pyproject_hooks.BuildBackendHookCaller.get_requires_for_build_wheel') builder = build.ProjectBuilder(package_test_flit) side_effects = [ [], ['something'], - pep517.wrappers.BackendUnavailable, + pyproject_hooks.BackendUnavailable, ] builder._hook.get_requires_for_build_sdist.side_effect = copy.copy(side_effects) @@ -293,7 +293,7 @@ def test_check_dependencies(mocker, package_test_flit): def test_build(mocker, package_test_flit, tmp_dir): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) @@ -314,7 +314,7 @@ def test_build(mocker, package_test_flit, tmp_dir): def test_default_backend(mocker, package_legacy): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_legacy) @@ -322,7 +322,7 @@ def test_default_backend(mocker, package_legacy): def test_missing_backend(mocker, package_test_no_backend): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_no_backend) @@ -330,21 +330,21 @@ def test_missing_backend(mocker, package_test_no_backend): def test_missing_requires(mocker, package_test_no_requires): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) with pytest.raises(build.BuildException): build.ProjectBuilder(package_test_no_requires) def test_build_system_typo(mocker, package_test_typo): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) with pytest.warns(build.TypoWarning): build.ProjectBuilder(package_test_typo) def test_missing_outdir(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) builder._hook.build_sdist.return_value = 'dist.tar.gz' @@ -356,7 +356,7 @@ def test_missing_outdir(mocker, tmp_dir, package_test_flit): def test_relative_outdir(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) builder._hook.build_sdist.return_value = 'dist.tar.gz' @@ -367,7 +367,7 @@ def test_relative_outdir(mocker, tmp_dir, package_test_flit): def test_build_not_dir_outdir(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) builder._hook.build_sdist.return_value = 'dist.tar.gz' @@ -437,7 +437,7 @@ def test_build_with_dep_on_console_script(tmp_path, demo_pkg_inline, capfd, mock def test_prepare(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) builder._hook.prepare_metadata_for_build_wheel.return_value = 'dist-1.0.dist-info' @@ -447,17 +447,17 @@ def test_prepare(mocker, tmp_dir, package_test_flit): def test_prepare_no_hook(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) - failure = pep517.wrappers.HookMissing('prepare_metadata_for_build_wheel') + failure = pyproject_hooks.HookMissing('prepare_metadata_for_build_wheel') builder._hook.prepare_metadata_for_build_wheel.side_effect = failure assert builder.prepare('wheel', tmp_dir) is None def test_prepare_error(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) builder._hook.prepare_metadata_for_build_wheel.side_effect = Exception @@ -467,7 +467,7 @@ def test_prepare_error(mocker, tmp_dir, package_test_flit): def test_prepare_not_dir_outdir(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) @@ -479,7 +479,7 @@ def test_prepare_not_dir_outdir(mocker, tmp_dir, package_test_flit): def test_no_outdir_single(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller.prepare_metadata_for_build_wheel', return_value='') + mocker.patch('pyproject_hooks.BuildBackendHookCaller.prepare_metadata_for_build_wheel', return_value='') builder = build.ProjectBuilder(package_test_flit) @@ -490,7 +490,7 @@ def test_no_outdir_single(mocker, tmp_dir, package_test_flit): def test_no_outdir_multiple(mocker, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller.prepare_metadata_for_build_wheel', return_value='') + mocker.patch('pyproject_hooks.BuildBackendHookCaller.prepare_metadata_for_build_wheel', return_value='') builder = build.ProjectBuilder(package_test_flit) @@ -564,7 +564,7 @@ def mock_tomli_not_available(mocker): @pytest.mark.skipif(sys.version_info >= (3, 11), reason='No need to test old toml support on 3.11+') def test_toml_instead_of_tomli(mocker, mock_tomli_not_available, tmp_dir, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) builder = build.ProjectBuilder(package_test_flit) builder._hook.build_sdist.return_value = 'dist.tar.gz' @@ -575,7 +575,7 @@ def test_toml_instead_of_tomli(mocker, mock_tomli_not_available, tmp_dir, packag def test_log(mocker, caplog, package_test_flit): - mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True) + mocker.patch('pyproject_hooks.BuildBackendHookCaller', autospec=True) mocker.patch('build.ProjectBuilder._call_backend', return_value='some_path') caplog.set_level(logging.DEBUG)