-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Prevent deprecated license classifiers from being written to core metadata #4833
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
Changes from 7 commits
6410380
778e679
ee51110
9bdad9f
ea4095d
3af67b8
3b71b5f
29302de
a20512e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Added exception (or warning) when deprecated license classifiers are used, | ||
| according to `PEP 639 <https://peps.python.org/pep-0639/#deprecate-license-classifiers>`_. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ | |
| import io | ||
| import re | ||
| import tarfile | ||
| import warnings | ||
| from inspect import cleandoc | ||
| from pathlib import Path | ||
| from unittest.mock import Mock | ||
|
|
@@ -24,7 +23,7 @@ | |
| from setuptools.config import expand, pyprojecttoml, setupcfg | ||
| from setuptools.config._apply_pyprojecttoml import _MissingDynamic, _some_attrgetter | ||
| from setuptools.dist import Distribution | ||
| from setuptools.errors import RemovedConfigError | ||
| from setuptools.errors import InvalidConfigError, RemovedConfigError | ||
| from setuptools.warnings import SetuptoolsDeprecationWarning | ||
|
|
||
| from .downloads import retrieve_file, urls_from_file | ||
|
|
@@ -320,25 +319,35 @@ def test_license_in_metadata( | |
| assert content_str in content | ||
|
|
||
|
|
||
| def test_license_expression_with_bad_classifier(tmp_path): | ||
| def test_license_classifier_with_license_expression(tmp_path): | ||
| text = PEP639_LICENSE_EXPRESSION.rsplit("\n", 2)[0] | ||
| pyproject = _pep621_example_project( | ||
| tmp_path, | ||
| "README", | ||
| f"{text}\n \"License :: OSI Approved :: MIT License\"\n]", | ||
| ) | ||
| msg = "License classifier are deprecated(?:.|\n)*'License :: OSI Approved :: MIT License'" | ||
| with pytest.raises(SetuptoolsDeprecationWarning, match=msg): | ||
| msg = "License classifiers have been superseded by license expressions" | ||
| with pytest.raises(InvalidConfigError, match=msg) as exc: | ||
| pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject) | ||
| assert "License :: OSI Approved :: MIT License" in str(exc.value) | ||
|
||
|
|
||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", SetuptoolsDeprecationWarning) | ||
|
|
||
| def test_license_classifier_without_license_expression(tmp_path): | ||
| text = """\ | ||
| [project] | ||
| name = "spam" | ||
| version = "2020.0.0" | ||
| license = {text = "mit or apache-2.0"} | ||
| classifiers = ["License :: OSI Approved :: MIT License"] | ||
| """ | ||
| pyproject = _pep621_example_project(tmp_path, "README", text) | ||
|
|
||
| msg = "License classifiers are deprecated(?:.|\n)*MIT License" | ||
| with pytest.warns(SetuptoolsDeprecationWarning, match=msg): | ||
| dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject) | ||
| # Check license classifier is still included | ||
| assert dist.metadata.get_classifiers() == [ | ||
| "Development Status :: 5 - Production/Stable", | ||
| "Programming Language :: Python", | ||
| "License :: OSI Approved :: MIT License", | ||
| "License :: OSI Approved :: MIT License" | ||
| ] | ||
|
||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't the the licensing user guide to be compelling just yet. Maybe a better location would be the
pyproject.tomlguide? https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license