diff --git a/__init__.py b/__init__.py index 0ae735c..446f42d 100644 --- a/__init__.py +++ b/__init__.py @@ -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 diff --git a/discovery.py b/discovery.py index 563d569..bf4525c 100644 --- a/discovery.py +++ b/discovery.py @@ -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' diff --git a/flit.py b/flit.py index 46a05f9..b3a22ea 100644 --- a/flit.py +++ b/flit.py @@ -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) diff --git a/metadata.py b/metadata.py index bddae05..86fb88f 100644 --- a/metadata.py +++ b/metadata.py @@ -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) @@ -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