Skip to content

Commit

Permalink
util: allow passing alternative runner to project_wheel_metadata (#566
Browse files Browse the repository at this point in the history
)

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: layday <layday@protonmail.com>

Closes #553
  • Loading branch information
q0w authored Jan 25, 2023
1 parent 01523ac commit e18ce1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changelog
Unreleased
==========

- Added ``runner`` parameter to ``util.project_wheel_metadata``
(`PR #566`_, Fixes `#553`_)
- Modified ``ProjectBuilder`` constructor signature,
added alternative ``ProjectBuilder.from_env`` constructor,
redefined ``env.IsolatedEnv`` interface, and exposed ``env.DefaultIsolatedEnv``,
Expand All @@ -15,7 +17,9 @@ Unreleased
from an ``IsolatedEnv`` in a consistent manner. Mutating the project builder is no longer supported.
(`PR #537`_)

.. _#553: https://github.com/pypa/build/issues/553
.. _PR #537: https://github.com/pypa/build/pull/537
.. _PR #566: https://github.com/pypa/build/pull/566


0.10.0 (2023-01-11)
Expand Down
9 changes: 6 additions & 3 deletions src/build/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pyproject_hooks

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


Expand All @@ -27,6 +27,8 @@ def _project_wheel_metadata(builder: ProjectBuilder) -> importlib_metadata.Packa
def project_wheel_metadata(
source_dir: PathType,
isolated: bool = True,
*,
runner: RunnerType = pyproject_hooks.quiet_subprocess_runner,
) -> importlib_metadata.PackageMetadata:
"""
Return the wheel metadata for a project.
Expand All @@ -38,22 +40,23 @@ def project_wheel_metadata(
:param isolated: Whether or not to run invoke the backend in the current
environment or to create an isolated one and invoke it
there.
:param runner: An alternative runner for backend subprocesses
"""

if isolated:
with DefaultIsolatedEnv() as env:
builder = ProjectBuilder.from_isolated_env(
env,
source_dir,
runner=pyproject_hooks.quiet_subprocess_runner,
runner=runner,
)
env.install(builder.build_system_requires)
env.install(builder.get_requires_for_build('wheel'))
return _project_wheel_metadata(builder)
else:
builder = ProjectBuilder(
source_dir,
runner=pyproject_hooks.quiet_subprocess_runner,
runner=runner,
)
return _project_wheel_metadata(builder)

Expand Down

0 comments on commit e18ce1c

Please sign in to comment.