Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: allow passing alternative runner to project_wheel_metadata #566

Merged
merged 6 commits into from
Jan 25, 2023
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: 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