scikit-build/dynamic-metadata

Requesting metadata proposal

henryiii opened this issue · 0 comments

Some hooks may want to access other's metadata. I think this could be supported in three stages:

First, the hooks could be redesigned to modify an existing dictionary of metadata in place. The new hook signature would be:

def dynamic_metadata(
    metadata: MutableMapping[str, str | dict[str, str | None] | list[str]],
    field: str,
    settings: Mapping[str, object] | None = None,
) -> None:
    "Modify the metadata inplace"

The contents of the metadata dict would include static metadata, and the hook is expected to replace or add field. At this stage, nothing is stated about the order of the hooks run.

Second stage could be to require version be computed before other hooks. I believe this is the current implantation in hatchling, and is the reason for adding this (hatch-fancy-pypi-readme requires the version pre-computed).

The third stage would be to add topological sorting. This would probably be easier to add after Python 3.9 becomes the minimum required version for most backends. A new hook would be added:

def metadata_reqiures(
    field: str,
    settings: Mapping[str, object] | None = None,
) -> list[str]:
    "Return fields needing to be computed first"

And backends should topologically sort before running.