Skip to content
Merged
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
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
'importlib_resources; python_version < "3.12"',
]

__license__ = 'Apache-2.0'

# honor PYTHONSAFEPATH (coherent-oss/system#21)
import jaraco.compat.py310.safe_path # noqa: F401

Expand Down
2 changes: 1 addition & 1 deletion discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ def declared_license():

Returns None if no ``__license__`` is declared.

>>> declared_license()
>>> monkeypatch = getfixture('monkeypatch')
>>> tmp_path = getfixture('tmp_path')
>>> monkeypatch.chdir(tmp_path)
>>> declared_license()
>>> _ = (tmp_path / '__init__.py').write_text('__license__ = "MIT"\\n')
>>> declared_license()
'MIT'
Expand Down
3 changes: 2 additions & 1 deletion flit.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,5 @@ def gen_files(self):
yield from super().gen_files()
yield 'pyproject.toml', render(self.metadata)
yield self.metadata.readme_filename, self.metadata['Description']
yield 'LICENSE', coherent.licensed.resolve(self.metadata['License-Expression'])
if license := self.metadata['License-Expression']:
yield 'LICENSE', coherent.licensed.resolve(license)
6 changes: 4 additions & 2 deletions metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def _discover_fields():
yield from discovery.best_description()
for classifier in discovery.generate_classifiers():
yield 'Classifier', classifier
yield 'License-Expression', discovery.declared_license() or 'Apache-2.0'
if license := discovery.declared_license():
yield 'License-Expression', license

@classmethod
@suppress(MetadataNotFound)
Expand Down Expand Up @@ -153,8 +154,9 @@ def render_toml(self):
"dependencies": self.get_all("Requires-Dist") or [],
"classifiers": self.get_all("Classifier") or [],
'urls': self.urls,
'license': self['License-Expression'],
}
if license := self['License-Expression']:
project['license'] = license

return project

Expand Down
Loading