-
Notifications
You must be signed in to change notification settings - Fork 49
feat(build): resolve build deps from dependency graph instead of PEP 517 hooks #1009
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| from .requirements_file import RequirementType | ||
|
|
||
| if typing.TYPE_CHECKING: | ||
| from . import context | ||
| from . import context, dependency_graph | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -314,6 +314,55 @@ def prepare_build_environment( | |
| return build_env | ||
|
|
||
|
|
||
| @metrics.timeit(description="prepare build environment from graph") | ||
| def prepare_build_environment_from_graph( | ||
| *, | ||
| ctx: context.WorkContext, | ||
| req: Requirement, | ||
| sdist_root_dir: pathlib.Path, | ||
| build_requirements: typing.Iterable[dependency_graph.DependencyNode], | ||
| ) -> BuildEnvironment: | ||
| """Create a build environment populated from pre-resolved graph dependencies. | ||
|
|
||
| Uses build requirements extracted from the dependency graph instead of | ||
| running PEP 517 discovery hooks. This is the preferred path for Stage 2 | ||
| build commands (build-sequence, build-parallel) where the graph is the | ||
| source of truth. | ||
| """ | ||
| logger.info("preparing build environment from dependency graph") | ||
|
|
||
| build_env = BuildEnvironment( | ||
| ctx=ctx, | ||
| parent_dir=sdist_root_dir.parent, | ||
| ) | ||
|
|
||
| reqs = { | ||
| Requirement(f"{node.canonicalized_name}=={node.version}") | ||
| for node in build_requirements | ||
| } | ||
| if reqs: | ||
| # Graph-resolved deps are a mix of build-system, build-backend, | ||
| # build-sdist, and their transitive install deps. We use | ||
| # BUILD_SYSTEM as the label since they all go into the build env. | ||
| _safe_install( | ||
| ctx=ctx, | ||
| req=req, | ||
| build_env=build_env, | ||
| deps=reqs, | ||
| dep_req_type=RequirementType.BUILD_SYSTEM, | ||
| ) | ||
|
Comment on lines
+343
to
+353
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t report mixed graph installs as This path installs a mix of build-system, build-backend, build-sdist, and transitive install deps. If 🤖 Prompt for AI Agents |
||
|
|
||
| try: | ||
| distributions = build_env.get_distributions() | ||
| except Exception: | ||
| # ignore error for debug call, error reason is logged in get_distributions() | ||
| pass | ||
| else: | ||
| logger.debug("build env %r has packages %r", build_env.path, distributions) | ||
|
|
||
| return build_env | ||
|
|
||
|
|
||
| def _safe_install( | ||
| ctx: context.WorkContext, | ||
| req: Requirement, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.