API reference¶
Loader¶
The driver consumed by build backends.
- dynamic_metadata.loader.dynamic_wheel_fields(entries)¶
Collect the fields to mark
Dynamicin SDist metadata (METADATA 2.2).Asks each provider’s optional
dynamic_wheelhook which fields may legitimately differ between the SDist and a wheel built from it. A field is dynamic if any provider reports itTrue: contributions to a field merge, so one dynamic part makes the merged value dynamic (PEP 643 permits marking a fieldDynamiceven when its value is also given). A field no provider mentions is not dynamic, andversionmay never be.Providers are loaded fresh here, so
dynamic_wheelcannot rely on state from adynamic_metadatacall.
- dynamic_metadata.loader.get_requires_for_dynamic_metadata(entries)¶
Collect every provider’s extra build requirements, in entry order.
Call this from each PEP 517
get_requires_for_build_*hook. A provider without the optionalget_requires_for_dynamic_metadatahook contributes nothing.
- dynamic_metadata.loader.load_dynamic_metadata(entries)¶
Load each entry’s provider, yielding it with its plugin settings.
Entries are processed in order;
provideris consumed here and the remaining keys are returned as plugin settings.
- dynamic_metadata.loader.load_provider(provider)¶
Load a provider from its config value, returning the object whose hooks are called.
provideris the value of theproviderkey in a[[tool.dynamic-metadata]]entry, in one of two forms:a string — a name registered in the
PROVIDER_GROUPentry-point group. Installed plugins are only reachable this way; a raw import path is not accepted.an inline table
{path, module}— a local plugin imported from thepathdirectory as a module path ("pkg.mod"or"pkg.mod:Class"), for a plugin living inside the project being built. Entry points are not consulted.
A bare module is returned as-is (hooks are module-level functions); a class is instantiated with no arguments so its hooks are bound methods sharing state through
self; an already-instantiated object is used directly.- Parameters:
provider (
object)- Return type:
- dynamic_metadata.loader.process_dynamic_metadata(project, entries, build_state)¶
Process dynamic metadata.
Takes the original
[project]table and an ordered list of[[tool.dynamic-metadata]]entries, and returns a new project table. Entries run in list order: each provider is called with a read-only snapshot of the project as resolved so far, so a later entry can read a field an earlier one produced viaproject[...]. A provider returns adictfragment of the project table ({field: value, ...}) which is merged in.build_stateis the backend’s description of the current build. It must be one of these build states (BUILD_STATES):"sdist","wheel","editable","metadata_wheel", or"metadata_editable". A provider that cares about it implements an optionalbuild_statehook, called with this value beforedynamic_metadata; providers that ignore it simply omit the hook.
Plugin protocols¶
The protocols a provider may implement. Every provider satisfies
DynamicMetadataProtocol; the others add optional hooks.
- class dynamic_metadata.protocols.DynamicMetadataProtocol(*args, **kwargs)¶
- class dynamic_metadata.protocols.DynamicMetadataBuildStateProtocol(*args, **kwargs)¶
- class dynamic_metadata.protocols.DynamicMetadataRequirementsProtocol(*args, **kwargs)¶
- class dynamic_metadata.protocols.DynamicMetadataWheelProtocol(*args, **kwargs)¶
Field taxonomy¶
The single source of truth for which [project] fields can be dynamic and what
shape their value has.
Plugin helpers¶
Shared helpers that bundled and third-party plugins can reuse.