dynamic-metadata#
This repo is to support https://github.com/scikit-build/scikit-build-core/issues/230.
[!WARNING]
This plugin is still a WiP!
For users#
Every external plugin must specify a “provider”, which is a module that provides the API listed in the next section.
[tool.dynamic-metadata]
<field-name>.provider = "<module>"
There is an optional field: “provider-path”, which specifies a local path to load a plugin from, allowing plugins to reside inside your own project.
All other fields are passed on to the plugin, allowing plugins to specify custom
configuration per field. Plugins can, if desired, use their own tool.*
sections as well; plugins only supporting one metadata field are more likely to
do this.
Example: regex#
An example regex plugin is provided in this package. It is used like this:
[build-system]
requires = ["...", "dynamic-metadata"]
build-backend = "..."
[project]
dynamic = ["version"]
[tool.dynamic-metadata.version]
provider = "dynamic_metadata.plugins.regex"
input = "src/my_package/__init__.py"
regex = '(?i)^(__version__|VERSION) *= *([\'"])v?(?P<value>.+?)\2'
In this case, since the plugin lives inside dynamic-metadata
, you have to
include that in your requirements. Make sure the version is marked dynamic in
your project table. And then you specify version.provider
. The other options
are defined by the plugin; this one takes a required input
file and an
optional regex
(which defaults to the expression you see above). The regex
optional regex
(which defaults to the expression you see above). The regex
needs to have a "value"
named group (?P<value>
), which it will set.