Skip to content

Commit

Permalink
Add support for license.text
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Kluyver <[email protected]>
  • Loading branch information
cdce8p and takluyver committed Feb 8, 2025
1 parent 2818f41 commit 786b207
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:
raise ConfigError(f"License file {license_f} does not exist")
license_files.add(license_tbl['file'])
elif 'text' in license_tbl:
pass
license = license_tbl['text']
# TODO Normalize license if it's a valid SPDX expression
md_dict['license'] = license
else:
raise ConfigError(
"file or text field required in [project.license] table"
Expand Down
13 changes: 13 additions & 0 deletions flit_core/tests_core/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ def test_bad_pep621_readme(readme, err_match):
config.read_pep621_metadata(proj, samples_dir / 'pep621' / 'pyproject.toml')


@pytest.mark.parametrize(('value', 'license'), [
# Accept any string in project.license.text
({"text": "mit"}, "mit"),
({"text": "Apache Software License"}, "Apache Software License"),
])
def test_license_text(value, license):
proj = {
'name': 'module1', 'version': '1.0', 'description': 'x', 'license': value
}
info = config.read_pep621_metadata(proj, samples_dir / 'pep621' / 'pyproject.toml')
assert info.metadata['license'] == license


@pytest.mark.parametrize(('value', 'license_expression'), [
# Accept and normalize valid SPDX expressions for 'license = ...'
("mit", "MIT"),
Expand Down

0 comments on commit 786b207

Please sign in to comment.