diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ed9908d8..fea1cfc0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -16,10 +16,10 @@ jobs: PY_COLORS: 1 TOX_PARALLEL_NO_SPINNER: 1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python 3.9 - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.9 @@ -29,5 +29,5 @@ jobs: - name: Setup run environment run: tox -vv --notest -e docs - - name: Run check for type + - name: Run check for docs run: tox -e docs --skip-pkg-install diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2cb2279..47dce016 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,10 +50,10 @@ jobs: - { py: '3.11-dev', os: windows } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup python for test ${{ matrix.py }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ matrix.py }} @@ -74,7 +74,7 @@ jobs: shell: python - name: Setup python for tox - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.9 @@ -116,10 +116,10 @@ jobs: PY_COLORS: 1 TOX_PARALLEL_NO_SPINNER: 1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python 3.9 - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.9 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bc08df8..16ae1536 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,11 @@ repos: rev: 22.3.0 hooks: - id: black +- repo: https://github.com/asottile/blacken-docs + rev: v1.12.1 + hooks: + - id: blacken-docs + additional_dependencies: [black==22.3.0] - repo: https://github.com/PyCQA/isort rev: 5.10.1 hooks: @@ -45,3 +50,14 @@ repos: hooks: - id: codespell args: ["-L", "sur"] +- repo: https://github.com/pre-commit/pygrep-hooks + rev: "v1.9.0" + hooks: + - id: python-check-blanket-noqa + - id: python-check-blanket-type-ignore + - id: python-no-log-warn + - id: python-no-eval + - id: python-use-type-annotations + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal diff --git a/.readthedocs.yml b/.readthedocs.yml index 60278c43..76beb6b2 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,7 +1,11 @@ version: 2 +build: + os: ubuntu-20.04 + tools: + python: '3.10' + python: - version: 3.8 install: - method: pip path: . diff --git a/CHANGELOG.rst b/CHANGELOG.rst index be92d0b1..c3b4009b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,10 +12,23 @@ Unreleased - Add schema validation for ``build-system`` table to check conformity with PEP 517 and PEP 518 (`PR #365`_, Fixes `#364`_) +- Better support for Python 3.11 (sysconfig schemes `PR #434`_, `PR #463`_, tomllib `PR #443`_, warnings `PR #420`_) + +- Improved error printouts (`PR #442`_) + +- Avoid importing packaging unless needed (`PR #395`_, Fixes `#393`_) + .. _PR #365: https://github.com/pypa/build/pull/365 .. _PR #392: https://github.com/pypa/build/pull/392 +.. _PR #395: https://github.com/pypa/build/pull/395 +.. _PR #420: https://github.com/pypa/build/pull/420 +.. _PR #434: https://github.com/pypa/build/pull/434 +.. _PR #442: https://github.com/pypa/build/pull/442 +.. _PR #443: https://github.com/pypa/build/pull/443 +.. _PR #463: https://github.com/pypa/build/pull/463 .. _#364: https://github.com/pypa/build/issues/364 .. _#372: https://github.com/pypa/build/issues/372 +.. _#393: https://github.com/pypa/build/pull/393 0.7.0 (16-09-2021) diff --git a/setup.cfg b/setup.cfg index f1ab1ad9..f314a613 100644 --- a/setup.cfg +++ b/setup.cfg @@ -64,7 +64,7 @@ test = typing = importlib-metadata>=4.6.4 mypy==0.942 - typing-extensions>=3.7.4.3 + typing-extensions>=3.7.4.3;python_version < "3.8" virtualenv = virtualenv>=20.0.35 diff --git a/src/build/__init__.py b/src/build/__init__.py index a6fa436f..ce742040 100644 --- a/src/build/__init__.py +++ b/src/build/__init__.py @@ -3,6 +3,7 @@ """ build - A simple, correct PEP 517 build frontend """ + __version__ = '0.7.0' import contextlib @@ -24,6 +25,7 @@ Callable, Dict, Iterator, + List, Mapping, MutableMapping, Optional, @@ -71,18 +73,18 @@ } -_logger = logging.getLogger('build') +_logger = logging.getLogger(__name__) class BuildException(Exception): """ - Exception raised by ProjectBuilder + Exception raised by :class:`ProjectBuilder` """ class BuildBackendException(Exception): """ - Exception raised when the backend fails + Exception raised when a backend operation fails """ def __init__( @@ -131,7 +133,7 @@ def __str__(self) -> str: class TypoWarning(Warning): """ - Warning raised when a potential typo is found + Warning raised when a possible typo is found """ @@ -428,12 +430,13 @@ def build( def metadata_path(self, output_directory: PathType) -> str: """ - Generates the metadata directory of a distribution and returns its path. + Generate the metadata directory of a distribution and return its path. If the backend does not support the ``prepare_metadata_for_build_wheel`` - hook, a wheel will be built and the metadata extracted. + hook, a wheel will be built and the metadata will be extracted from it. :param output_directory: Directory to put the metadata distribution in + :returns: The path of the metadata directory """ # prepare_metadata hook metadata = self.prepare('wheel', output_directory) @@ -491,12 +494,12 @@ def _handle_backend(self, hook: str) -> Iterator[None]: @staticmethod def log(message: str) -> None: """ - Prints message + Log a message. The default implementation uses the logging module but this function can be - overwritten by users to have a different implementation. + overridden by users to have a different implementation. - :param msg: Message to output + :param message: Message to output """ if sys.version_info >= (3, 8): _logger.log(logging.INFO, message, stacklevel=2) @@ -504,7 +507,7 @@ def log(message: str) -> None: _logger.log(logging.INFO, message) -__all__ = ( +__all__ = [ '__version__', 'BuildBackendException', 'BuildException', @@ -514,4 +517,8 @@ def log(message: str) -> None: 'RunnerType', 'TypoWarning', 'check_dependency', -) +] + + +def __dir__() -> List[str]: + return __all__ diff --git a/src/build/__main__.py b/src/build/__main__.py index 843564bd..df244cc9 100644 --- a/src/build/__main__.py +++ b/src/build/__main__.py @@ -79,7 +79,7 @@ def _error(msg: str, code: int = 1) -> NoReturn: # pragma: no cover :param code: Error code """ print('{red}ERROR{reset} {}'.format(msg, **_STYLES)) - exit(code) + raise SystemExit(code) class _ProjectBuilder(ProjectBuilder): diff --git a/tests/test_env.py b/tests/test_env.py index 37446ca7..a1ee0cbe 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -82,7 +82,7 @@ def test_isolated_env_abstract(): def test_isolated_env_has_executable_still_abstract(): - class Env(build.env.IsolatedEnv): # noqa + class Env(build.env.IsolatedEnv): @property def executable(self): raise NotImplementedError @@ -92,7 +92,7 @@ def executable(self): def test_isolated_env_has_install_still_abstract(): - class Env(build.env.IsolatedEnv): # noqa + class Env(build.env.IsolatedEnv): def install(self, requirements): raise NotImplementedError diff --git a/tests/test_module.py b/tests/test_module.py index 87cc631e..1d3d1cc1 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -1,7 +1,16 @@ # SPDX-License-Identifier: MIT +import sys + +import pytest + import build def test_version(): assert build.__version__ + + +@pytest.mark.skipif(sys.version_info < (3, 7), reason='Python 3.7+ required for dir support') +def test_dir(): + assert set(dir(build)) == set(build.__all__) diff --git a/tox.ini b/tox.ini index f3d6d57a..1d3e9eef 100644 --- a/tox.ini +++ b/tox.ini @@ -107,3 +107,4 @@ depends = {py311, py310, py39, py38, py37, py36, pypy37, pypy38, pypy39} max-line-length = 127 max-complexity = 10 extend-ignore = E203 +extend-select = B9