Skip to content

Commit

Permalink
Do not redefine the runner protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
layday committed Dec 9, 2023
1 parent ef12982 commit a29804d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
23 changes: 6 additions & 17 deletions src/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
FailedProcessError,
TypoWarning,
)
from ._util import Protocol, check_dependency, parse_wheel_filename
from ._util import check_dependency, parse_wheel_filename


if sys.version_info >= (3, 11):
Expand All @@ -40,18 +40,6 @@
import tomli as tomllib


class RunnerType(Protocol):
"""A protocol for the subprocess runner."""

def __call__(
self,
cmd: Sequence[str],
cwd: str | None = None,
extra_environ: Mapping[str, str] | None = None,
) -> None:
...


ConfigSettingsType = Mapping[str, Union[str, Sequence[str]]]
PathType = Union[str, 'os.PathLike[str]']

Expand Down Expand Up @@ -146,7 +134,9 @@ def _parse_build_system_table(pyproject_toml: Mapping[str, Any]) -> Mapping[str,
return build_system_table


def _wrap_subprocess_runner(runner: RunnerType, env: env.IsolatedEnv) -> RunnerType:
def _wrap_subprocess_runner(
runner: pyproject_hooks.SubprocessRunner, env: env.IsolatedEnv
) -> pyproject_hooks.SubprocessRunner:
def _invoke_wrapped_runner(
cmd: Sequence[str], cwd: str | None = None, extra_environ: Mapping[str, str] | None = None
) -> None:
Expand All @@ -164,7 +154,7 @@ def __init__(
self,
source_dir: PathType,
python_executable: str = sys.executable,
runner: RunnerType = pyproject_hooks.default_subprocess_runner,
runner: pyproject_hooks.SubprocessRunner = pyproject_hooks.default_subprocess_runner,
) -> None:
"""
:param source_dir: The source directory
Expand Down Expand Up @@ -207,7 +197,7 @@ def from_isolated_env(
cls: type[_TProjectBuilder],
env: env.IsolatedEnv,
source_dir: PathType,
runner: RunnerType = pyproject_hooks.default_subprocess_runner,
runner: pyproject_hooks.SubprocessRunner = pyproject_hooks.default_subprocess_runner,
) -> _TProjectBuilder:
return cls(
source_dir=source_dir,
Expand Down Expand Up @@ -398,7 +388,6 @@ def log(message: str) -> None:
'ConfigSettingsType',
'FailedProcessError',
'ProjectBuilder',
'RunnerType',
'TypoWarning',
'check_dependency',
]
Expand Down
4 changes: 2 additions & 2 deletions src/build/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pyproject_hooks

from . import PathType, ProjectBuilder, RunnerType
from . import PathType, ProjectBuilder
from ._importlib import metadata
from .env import DefaultIsolatedEnv

Expand All @@ -22,7 +22,7 @@ def project_wheel_metadata(
source_dir: PathType,
isolated: bool = True,
*,
runner: RunnerType = pyproject_hooks.quiet_subprocess_runner,
runner: pyproject_hooks.SubprocessRunner = pyproject_hooks.quiet_subprocess_runner,
) -> metadata.PackageMetadata:
"""
Return the wheel metadata for a project.
Expand Down

0 comments on commit a29804d

Please sign in to comment.