feat: provide the backend collection loops in the loader#78
Merged
Conversation
Add get_requires_for_dynamic_metadata(entries) and dynamic_wheel_fields(entries) to loader.py, replacing the copy-paste snippets on the backend-authors page. dynamic_wheel_fields enforces the spec rules the snippet only stated in prose: unknown fields are rejected, 'version' may never be dynamic, and unmentioned fields default to not dynamic. Same-field reports from multiple providers combine with OR rather than last-wins: contributions to a field merge, so one dynamic part makes the merged value dynamic, and PEP 643 only permits over-marking. The full loops (with validation) move to the reimplement page, and the plugin-author docs note dynamic_wheel may run on a fresh instance. Assisted-by: ClaudeCode:claude-fable-5
henryiii
added a commit
to scikit-build/scikit-build-core
that referenced
this pull request
Jul 2, 2026
dynamic_wheel_fields merged provider reports with dict.update, so when
two [[tool.dynamic-metadata]] entries reported the same field the last
one won -- a later {"dependencies": False} could retract an earlier
{"dependencies": True}. Since a list/table field's merged value can
change if any contributing provider's part may, reports must combine
with OR (any True wins); over-marking Dynamic is allowed, under-marking
violates PEP 643. Validation now runs on each fragment as it is
collected, so a masked {"version": True} raises instead of being
silently dropped. Aligns with scikit-build/dynamic-metadata#78.
Closes #1436
Assisted-by: ClaudeCode:claude-opus-4.8
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Prompted by scikit-build/scikit-build-core#1433: the first real consumer of the
dynamic_wheelhook had to write the collection loop itself, including validation rules our docs only stated in prose. The reference implementation should provide these loops so backends don't each re-derive spec rules.Changes
loader.py: two new public functions, replacing the copy-paste snippets on the backend-authors page:get_requires_for_dynamic_metadata(entries) -> list[str]— extra build requirements, collected in entry order, for the backend's PEP 517get_requires_for_build_*hooks.dynamic_wheel_fields(entries) -> set[str]— the METADATA 2.2 pass, now enforcing the rules the old doc snippet lacked: reported field names are validated againstALL_FIELDS,version: Trueraises, and unmentioned fields default to not dynamic.Truewins) rather than last-winsdict.update. Contributions to a field merge, so one dynamic part makes the merged value dynamic; PEP 643 permits over-marking but not under-marking. (Issue to align scikit-build-core to follow.)backend_authors.mdcalls the real functions; the full loops (with validation) move tobackend_authors_reimplement.mdas the copyable reference;plugin_authors.mdnotesdynamic_wheelmay run on a fresh instance, so it cannot rely on state stashed bydynamic_metadata/build_state(it only receivessettingsby design).versionrule; these replace the old test that hand-rolled the loop.The new functions appear in the API reference automatically via the existing
automoduledirective.