Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for license.text #716

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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