From 0f1f84eaa602a37c62dcd5fd7c911c1bc9cdf2a5 Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 29 Mar 2024 16:47:09 +0200 Subject: [PATCH 1/2] build: add `editable` to dist type Closes #763. --- src/build/_builder.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/build/_builder.py b/src/build/_builder.py index cfd7a5ef..82ea7f5b 100644 --- a/src/build/_builder.py +++ b/src/build/_builder.py @@ -11,7 +11,7 @@ import zipfile from collections.abc import Iterator -from typing import Any, Mapping, Sequence, TypeVar +from typing import Any, Literal, Mapping, Sequence, TypeVar import pyproject_hooks @@ -203,7 +203,11 @@ def build_system_requires(self) -> set[str]: """ return set(self._build_system['requires']) - def get_requires_for_build(self, distribution: Distribution, config_settings: ConfigSettings | None = None) -> set[str]: + def get_requires_for_build( + self, + distribution: Literal[Distribution, 'editable'], + config_settings: ConfigSettings | None = None, + ) -> set[str]: """ Return the dependencies defined by the backend in addition to :attr:`build_system_requires` for a given distribution. @@ -220,7 +224,9 @@ def get_requires_for_build(self, distribution: Distribution, config_settings: Co return set(get_requires(config_settings)) def check_dependencies( - self, distribution: Distribution, config_settings: ConfigSettings | None = None + self, + distribution: Literal[Distribution, 'editable'], + config_settings: ConfigSettings | None = None, ) -> set[tuple[str, ...]]: """ Return the dependencies which are not satisfied from the combined set of @@ -236,7 +242,7 @@ def check_dependencies( def prepare( self, - distribution: Distribution, + distribution: Literal[Distribution, 'editable'], output_directory: StrPath, config_settings: ConfigSettings | None = None, ) -> str | None: @@ -263,7 +269,7 @@ def prepare( def build( self, - distribution: Distribution, + distribution: Literal[Distribution, 'editable'], output_directory: StrPath, config_settings: ConfigSettings | None = None, metadata_directory: str | None = None, From 673ccf3d851cc8fecdac5288885fbf5bde6f8116 Mon Sep 17 00:00:00 2001 From: layday Date: Thu, 4 Apr 2024 00:40:33 +0300 Subject: [PATCH 2/2] Merge literals --- src/build/_builder.py | 10 +++++----- src/build/_types.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/build/_builder.py b/src/build/_builder.py index 82ea7f5b..857a8b08 100644 --- a/src/build/_builder.py +++ b/src/build/_builder.py @@ -11,7 +11,7 @@ import zipfile from collections.abc import Iterator -from typing import Any, Literal, Mapping, Sequence, TypeVar +from typing import Any, Mapping, Sequence, TypeVar import pyproject_hooks @@ -205,7 +205,7 @@ def build_system_requires(self) -> set[str]: def get_requires_for_build( self, - distribution: Literal[Distribution, 'editable'], + distribution: Distribution, config_settings: ConfigSettings | None = None, ) -> set[str]: """ @@ -225,7 +225,7 @@ def get_requires_for_build( def check_dependencies( self, - distribution: Literal[Distribution, 'editable'], + distribution: Distribution, config_settings: ConfigSettings | None = None, ) -> set[tuple[str, ...]]: """ @@ -242,7 +242,7 @@ def check_dependencies( def prepare( self, - distribution: Literal[Distribution, 'editable'], + distribution: Distribution, output_directory: StrPath, config_settings: ConfigSettings | None = None, ) -> str | None: @@ -269,7 +269,7 @@ def prepare( def build( self, - distribution: Literal[Distribution, 'editable'], + distribution: Distribution, output_directory: StrPath, config_settings: ConfigSettings | None = None, metadata_directory: str | None = None, diff --git a/src/build/_types.py b/src/build/_types.py index f1568bc8..1f2be1b8 100644 --- a/src/build/_types.py +++ b/src/build/_types.py @@ -5,7 +5,7 @@ ConfigSettings = typing.Mapping[str, typing.Union[str, typing.Sequence[str]]] -Distribution = typing.Literal['sdist', 'wheel'] +Distribution = typing.Literal['sdist', 'wheel', 'editable'] StrPath = typing.Union[str, 'os.PathLike[str]'] SubprocessRunner = typing.Callable[ [typing.Sequence[str], typing.Optional[str], typing.Optional[typing.Mapping[str, str]]], None