@@ -15,7 +15,7 @@ https://github.com/scikit-build/scikit-build-core/issues/230.
1515
1616> [ !WARNING]
1717>
18- > This plugin is still a WiP!
18+ > This is still a WiP! The design may still change.
1919
2020## For users
2121
@@ -64,16 +64,16 @@ needs to have a `"value"` named group (`?P<value>`), which it will set.
6464
6565** You do not need to depend on dynamic-metadata to write a plugin.** This
6666library provides testing and static typing helpers that are not needed at
67- runtime.
67+ runtime, along with a reference implementation that you can either use as
68+ an example, or use directly if you are fine to require the dependency.
6869
6970Like PEP 517's hooks, ` dynamic-metadata ` defines a set of hooks that you can
7071implement; one required hook and two optional hooks. The required hook is:
7172
7273``` python
7374def dynamic_metadata (
74- field : str ,
75- settings : dict[str , object ] | None = None ,
76- ) -> str | dict[str , str | None ]: ... # return the value of the metadata
75+ field : str , settings : Mapping[str , Any], project : Mapping[str , Any]
76+ ) -> str | dict[str , Any]: ... # return the value of the metadata
7777```
7878
7979The backend will call this hook in the same directory as PEP 517's hooks.
@@ -84,7 +84,8 @@ A plugin can return METADATA 2.2 dynamic status:
8484
8585``` python
8686def dynamic_wheel (
87- field : str , settings : Mapping[str , Any] | None = None
87+ field : str ,
88+ settings : Mapping[str , Any],
8889) -> (
8990 bool
9091): ... # Return true if metadata can change from SDist to wheel (METADATA 2.2 feature)
@@ -98,7 +99,7 @@ A plugin can also decide at runtime if it needs extra dependencies:
9899
99100``` python
100101def get_requires_for_dynamic_metadata (
101- settings : Mapping[str , Any] | None = None ,
102+ settings : Mapping[str , Any],
102103) -> list[str ]: ... # return list of packages to require
103104```
104105
@@ -113,6 +114,7 @@ Here is the regex plugin example implementation:
113114def dynamic_metadata (
114115 field : str ,
115116 settings : Mapping[str , Any],
117+ _project : Mapping[str , Any],
116118) -> str :
117119 # Input validation
118120 if field not in {" version" , " description" , " requires-python" }:
@@ -147,36 +149,9 @@ library provides some helper functions you can use if you want, but you can
147149implement them yourself following the standard provided or vendor the helper
148150file (which will be tested and supported).
149151
150- You should collect the contents of ` tool.dynamic-metadata ` and load each,
151- something like this:
152-
153- ``` python
154- def load_provider (
155- provider : str ,
156- provider_path : str | None = None ,
157- ) -> DynamicMetadataProtocol:
158- if provider_path is None :
159- return importlib.import_module(provider)
160-
161- if not Path(provider_path).is_dir():
162- msg = " provider-path must be an existing directory"
163- raise AssertionError (msg)
164-
165- try :
166- sys.path.insert(0 , provider_path)
167- return importlib.import_module(provider)
168- finally :
169- sys.path.pop(0 )
170-
171-
172- for dynamic_metadata in settings.metadata.values():
173- if " provider" in dynamic_metadata:
174- config = dynamic_metadata.copy()
175- provider = config.pop(" provider" )
176- provider_path = config.pop(" provider-path" , None )
177- module = load_provider(provider, provider_path)
178- # Run hooks from module
179- ```
152+ You should collect the contents of ` tool.dynamic-metadata ` and load each one.
153+ You should respect requests for metadata from other plugins, as well; to see
154+ how to do that, refer to ` src/dynamic-metadata/loader.py ` .
180155
181156<!-- prettier-ignore-start -->
182157[ actions-badge ] : https://github.com/scikit-build/dynamic-metadata/workflows/CI/badge.svg
0 commit comments