Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup Python 3.9
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: "3.10"

- name: Install tox
run: python -m pip install tox
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
- "3.9"
- "3.8"
- "3.7"
- "3.6"
tox-target:
- "tox"
- "min"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
rev: v3.1.0
hooks:
- id: pyupgrade
args: ["--py36-plus"]
args: ["--py37-plus"]
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ Unreleased

- Change build backend from ``setuptools`` to ``flit``
(`PR #470`_, Fixes `#394`_)
- Dropped support for Python 3.6 (`PR #532`_)

.. _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


Expand Down
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@
# html_static_path = ['_static']

autoclass_content = 'both'

nitpick_ignore = [
# https://github.com/python/importlib_metadata/issues/316
('py:class', 'importlib.metadata._meta.PackageMetadata'),
]
6 changes: 2 additions & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ Compatibility
``build`` is verified to be compatible with the following Python
versions:

- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- PyPy(2)
- 3.10
- 3.11
- PyPy3


Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "build"
version = "0.9.0"
description = "A simple, correct PEP 517 build frontend"
readme = "README.md"
requires-python = ">= 3.6"
requires-python = ">= 3.7"
license.file = "LICENSE"
authors = [
{ name = "Filipe Laíns", email = "[email protected]" },
Expand All @@ -19,7 +19,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down Expand Up @@ -117,7 +116,7 @@ filterwarnings = [

[tool.mypy]
files = "src"
python_version = "3.6"
python_version = "3.7"
strict = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "truthy-bool", "redundant-expr"]
Expand All @@ -133,7 +132,7 @@ ignore_missing_imports = true
[tool.black]
line-length = 127
skip-string-normalization = true
target-version = ["py39", "py38", "py37", "py36"]
target-version = ["py311", "py310", "py39", "py38", "py37"]

[tool.isort]
profile = "black"
Expand Down
63 changes: 24 additions & 39 deletions src/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
build - A simple, correct PEP 517 build frontend
"""

from __future__ import annotations


__version__ = '0.9.0'

import contextlib
Expand All @@ -19,27 +22,13 @@
import zipfile

from collections import OrderedDict
from typing import (
AbstractSet,
Any,
Callable,
Dict,
Iterator,
List,
Mapping,
MutableMapping,
Optional,
Sequence,
Set,
Tuple,
Type,
Union,
)
from collections.abc import Iterator, Set
from typing import Any, Callable, Mapping, MutableMapping, Optional, Sequence, Tuple, Type, Union

import pep517.wrappers


TOMLDecodeError: Type[Exception]
TOMLDecodeError: type[Exception]
toml_loads: Callable[[str], MutableMapping[str, Any]]

if sys.version_info >= (3, 11):
Expand Down Expand Up @@ -88,7 +77,7 @@ class BuildBackendException(Exception):
"""

def __init__(
self, exception: Exception, description: Optional[str] = None, exc_info: _ExcInfoType = (None, None, None)
self, exception: Exception, description: str | None = None, exc_info: _ExcInfoType = (None, None, None)
) -> None:
super().__init__()
self.exception = exception
Expand Down Expand Up @@ -159,8 +148,8 @@ def _validate_source_directory(srcdir: PathType) -> None:


def check_dependency(
req_string: str, ancestral_req_strings: Tuple[str, ...] = (), parent_extras: AbstractSet[str] = frozenset()
) -> Iterator[Tuple[str, ...]]:
req_string: str, ancestral_req_strings: tuple[str, ...] = (), parent_extras: Set[str] = frozenset()
) -> Iterator[tuple[str, ...]]:
"""
Verify that a dependency and all of its dependencies are met.

Expand Down Expand Up @@ -217,7 +206,7 @@ def _find_typo(dictionary: Mapping[str, str], expected: str) -> None:
)


def _parse_build_system_table(pyproject_toml: Mapping[str, Any]) -> Dict[str, Any]:
def _parse_build_system_table(pyproject_toml: Mapping[str, Any]) -> dict[str, Any]:
# If pyproject.toml is missing (per PEP 517) or [build-system] is missing
# (per PEP 518), use default values
if 'build-system' not in pyproject_toml:
Expand Down Expand Up @@ -265,7 +254,7 @@ def __init__(
self,
srcdir: PathType,
python_executable: str = sys.executable,
scripts_dir: Optional[str] = None,
scripts_dir: str | None = None,
runner: RunnerType = pep517.wrappers.default_subprocess_runner,
) -> None:
"""
Expand Down Expand Up @@ -313,12 +302,10 @@ def __init__(
runner=self._runner,
)

def _runner(
self, cmd: Sequence[str], cwd: Optional[str] = None, extra_environ: Optional[Mapping[str, str]] = None
) -> None:
def _runner(self, cmd: Sequence[str], cwd: str | None = None, extra_environ: Mapping[str, str] | None = None) -> None:
# if script dir is specified must be inserted at the start of PATH (avoid duplicate path while doing so)
if self.scripts_dir is not None:
paths: Dict[str, None] = OrderedDict()
paths: dict[str, None] = OrderedDict()
paths[str(self.scripts_dir)] = None
if 'PATH' in os.environ:
paths.update((i, None) for i in os.environ['PATH'].split(os.pathsep))
Expand All @@ -345,26 +332,26 @@ def python_executable(self, value: str) -> None:
self._hook.python_executable = value

@property
def scripts_dir(self) -> Optional[str]:
def scripts_dir(self) -> str | None:
"""
The folder where the scripts are stored for the python executable.
"""
return self._scripts_dir

@scripts_dir.setter
def scripts_dir(self, value: Optional[str]) -> None:
def scripts_dir(self, value: str | None) -> None:
self._scripts_dir = value

@property
def build_system_requires(self) -> Set[str]:
def build_system_requires(self) -> set[str]:
"""
The dependencies defined in the ``pyproject.toml``'s
``build-system.requires`` field or the default build dependencies
if ``pyproject.toml`` is missing or ``build-system`` is undefined.
"""
return set(self._build_system['requires'])

def get_requires_for_build(self, distribution: str, config_settings: Optional[ConfigSettingsType] = None) -> Set[str]:
def get_requires_for_build(self, distribution: str, config_settings: ConfigSettingsType | None = None) -> set[str]:
"""
Return the dependencies defined by the backend in addition to
:attr:`build_system_requires` for a given distribution.
Expand All @@ -380,9 +367,7 @@ def get_requires_for_build(self, distribution: str, config_settings: Optional[Co
with self._handle_backend(hook_name):
return set(get_requires(config_settings))

def check_dependencies(
self, distribution: str, config_settings: Optional[ConfigSettingsType] = None
) -> Set[Tuple[str, ...]]:
def check_dependencies(self, distribution: str, config_settings: ConfigSettingsType | None = None) -> set[tuple[str, ...]]:
"""
Return the dependencies which are not satisfied from the combined set of
:attr:`build_system_requires` and :meth:`get_requires_for_build` for a given
Expand All @@ -396,8 +381,8 @@ def check_dependencies(
return {u for d in dependencies for u in check_dependency(d)}

def prepare(
self, distribution: str, output_directory: PathType, config_settings: Optional[ConfigSettingsType] = None
) -> Optional[str]:
self, distribution: str, output_directory: PathType, config_settings: ConfigSettingsType | None = None
) -> str | None:
"""
Prepare metadata for a distribution.

Expand All @@ -423,8 +408,8 @@ def build(
self,
distribution: str,
output_directory: PathType,
config_settings: Optional[ConfigSettingsType] = None,
metadata_directory: Optional[str] = None,
config_settings: ConfigSettingsType | None = None,
metadata_directory: str | None = None,
) -> str:
"""
Build a distribution.
Expand Down Expand Up @@ -470,7 +455,7 @@ def metadata_path(self, output_directory: PathType) -> str:
return os.path.join(output_directory, distinfo)

def _call_backend(
self, hook_name: str, outdir: PathType, config_settings: Optional[ConfigSettingsType] = None, **kwargs: Any
self, hook_name: str, outdir: PathType, config_settings: ConfigSettingsType | None = None, **kwargs: Any
) -> str:
outdir = os.path.abspath(outdir)

Expand Down Expand Up @@ -535,5 +520,5 @@ def log(message: str) -> None:
]


def __dir__() -> List[str]:
def __dir__() -> list[str]:
return __all__
30 changes: 16 additions & 14 deletions src/build/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: MIT

from __future__ import annotations

import argparse
import contextlib
Expand All @@ -14,7 +15,8 @@
import traceback
import warnings

from typing import Dict, Iterator, List, NoReturn, Optional, Sequence, TextIO, Type, Union
from collections.abc import Iterator, Sequence
from typing import NoReturn, TextIO

import build

Expand All @@ -34,7 +36,7 @@
_NO_COLORS = {color: '' for color in _COLORS}


def _init_colors() -> Dict[str, str]:
def _init_colors() -> dict[str, str]:
if 'NO_COLOR' in os.environ:
if 'FORCE_COLOR' in os.environ:
warnings.warn('Both NO_COLOR and FORCE_COLOR environment variables are set, disabling color')
Expand All @@ -52,12 +54,12 @@ def _cprint(fmt: str = '', msg: str = '') -> None:


def _showwarning(
message: Union[Warning, str],
category: Type[Warning],
message: Warning | str,
category: type[Warning],
filename: str,
lineno: int,
file: Optional[TextIO] = None,
line: Optional[str] = None,
file: TextIO | None = None,
line: str | None = None,
) -> None: # pragma: no cover
_cprint('{yellow}WARNING{reset} {}', str(message))

Expand Down Expand Up @@ -102,7 +104,7 @@ def _format_dep_chain(dep_chain: Sequence[str]) -> str:


def _build_in_isolated_env(
builder: ProjectBuilder, outdir: PathType, distribution: str, config_settings: Optional[ConfigSettingsType]
builder: ProjectBuilder, outdir: PathType, distribution: str, config_settings: ConfigSettingsType | None
) -> str:
with _IsolatedEnvBuilder() as env:
builder.python_executable = env.executable
Expand All @@ -118,7 +120,7 @@ def _build_in_current_env(
builder: ProjectBuilder,
outdir: PathType,
distribution: str,
config_settings: Optional[ConfigSettingsType],
config_settings: ConfigSettingsType | None,
skip_dependency_check: bool = False,
) -> str:
if not skip_dependency_check:
Expand All @@ -136,7 +138,7 @@ def _build(
builder: ProjectBuilder,
outdir: PathType,
distribution: str,
config_settings: Optional[ConfigSettingsType],
config_settings: ConfigSettingsType | None,
skip_dependency_check: bool,
) -> str:
if isolation:
Expand Down Expand Up @@ -186,7 +188,7 @@ def build_package(
srcdir: PathType,
outdir: PathType,
distributions: Sequence[str],
config_settings: Optional[ConfigSettingsType] = None,
config_settings: ConfigSettingsType | None = None,
isolation: bool = True,
skip_dependency_check: bool = False,
) -> Sequence[str]:
Expand All @@ -200,7 +202,7 @@ def build_package(
:param isolation: Isolate the build in a separate environment
:param skip_dependency_check: Do not perform the dependency check
"""
built: List[str] = []
built: list[str] = []
builder = _ProjectBuilder(srcdir)
for distribution in distributions:
out = _build(isolation, builder, outdir, distribution, config_settings, skip_dependency_check)
Expand All @@ -212,7 +214,7 @@ def build_package_via_sdist(
srcdir: PathType,
outdir: PathType,
distributions: Sequence[str],
config_settings: Optional[ConfigSettingsType] = None,
config_settings: ConfigSettingsType | None = None,
isolation: bool = True,
skip_dependency_check: bool = False,
) -> Sequence[str]:
Expand All @@ -234,7 +236,7 @@ def build_package_via_sdist(

sdist_name = os.path.basename(sdist)
sdist_out = tempfile.mkdtemp(prefix='build-via-sdist-')
built: List[str] = []
built: list[str] = []
# extract sdist
with tarfile.open(sdist) as t:
t.extractall(sdist_out)
Expand Down Expand Up @@ -328,7 +330,7 @@ def main_parser() -> argparse.ArgumentParser:
return parser


def main(cli_args: Sequence[str], prog: Optional[str] = None) -> None: # noqa: C901
def main(cli_args: Sequence[str], prog: str | None = None) -> None: # noqa: C901
"""
Parse the CLI arguments and invoke the build process.

Expand Down
Loading