-
Notifications
You must be signed in to change notification settings - Fork 20
Description
PEP 639 states in https://peps.python.org/pep-0639/#deprecate-license-key-table-subkeys:
If the specified license
fileis present in the source tree, build tools SHOULD use it to fill theLicense-Filefield in the core metadata, and MUST include the specified file as if it were specified in alicense-filefield. If the file does not exist at the specified path, tools MUST raise an informative error as previously specified.
Currently, to do this, I need to have custom logic in my build backend to coerce things according to that section:
metadata: pyproject_metadata.StandardMetadata
if (
metadata.license is not None
and not isinstance(metadata.license, str)
and metadata.license.file is not None
):
license_file = metadata.license.file
if not license_file.exists():
raise ImproperProjectMetadata(
message="Declared license file does not exist.",
causes=[
f"Looked at {license_file}",
"Specified in pyproject.toml -> [project] -> license -> file",
],
hint_stmt="Did you specify the correct path?",
code="license-file-missing",
)
if metadata.license_files is None:
metadata.license_files = [license_file]
elif license_file not in metadata.license_files:
metadata.license_files.append(license_file)It would be good to have pyproject-metadata handle this, via some mechanism. For backwards-compatibility reasons, this might need to be an opt-in -- but that's fine, I'd be happy to adopt that in sphinx-theme-builder.