-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial support for License-Expression (PEP 639)
- Loading branch information
Showing
7 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added initial support for ``License-Expression`` (`PEP 639 <https://peps.python.org/pep-0639/#add-license-expression-field>`_). -- by :user:`cdce8p` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ backend-path = ["."] | |
[project] | ||
name = "setuptools" | ||
version = "75.2.0" | ||
license = "MIT" | ||
authors = [ | ||
{ name = "Python Packaging Authority", email = "[email protected]" }, | ||
] | ||
|
@@ -14,7 +15,6 @@ readme = "README.rst" | |
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
|
@@ -135,7 +135,7 @@ type = [ | |
|
||
# pin mypy version so a new version doesn't suddenly cause the CI to fail, | ||
# until types-setuptools is removed from typeshed. | ||
# For help with static-typing issues, or mypy update, ping @Avasam | ||
# For help with static-typing issues, or mypy update, ping @Avasam | ||
"mypy==1.12.*", | ||
# Typing fixes in version newer than we require at runtime | ||
"importlib_metadata>=7.0.2; python_version < '3.10'", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,28 @@ def main_gui(): pass | |
def main_tomatoes(): pass | ||
""" | ||
|
||
PEP639_LICENSE_TEXT = """\ | ||
[project] | ||
name = "spam" | ||
version = "2020.0.0" | ||
authors = [ | ||
{email = "[email protected]"}, | ||
{name = "Tzu-Ping Chung"} | ||
] | ||
license = {text = "MIT"} | ||
""" | ||
|
||
PEP639_LICENSE_EXPRESSION = """\ | ||
[project] | ||
name = "spam" | ||
version = "2020.0.0" | ||
authors = [ | ||
{email = "[email protected]"}, | ||
{name = "Tzu-Ping Chung"} | ||
] | ||
license = "MIT" | ||
""" | ||
|
||
|
||
def _pep621_example_project( | ||
tmp_path, | ||
|
@@ -250,6 +272,47 @@ def test_utf8_maintainer_in_metadata( # issue-3663 | |
assert f"Maintainer-email: {expected_maintainers_meta_value}" in content | ||
|
||
|
||
@pytest.mark.parametrize( | ||
('pyproject_text', 'license', 'license_expression', 'content_str'), | ||
( | ||
pytest.param( | ||
PEP639_LICENSE_TEXT, | ||
'MIT', | ||
None, | ||
'License: MIT', | ||
id='license-text', | ||
), | ||
pytest.param( | ||
PEP639_LICENSE_EXPRESSION, | ||
None, | ||
'MIT', | ||
'License-Expression: MIT', | ||
id='license-expression', | ||
), | ||
), | ||
) | ||
def test_license_in_metadata( | ||
license, | ||
license_expression, | ||
content_str, | ||
pyproject_text, | ||
tmp_path, | ||
): | ||
pyproject = _pep621_example_project( | ||
tmp_path, | ||
"README", | ||
pyproject_text=pyproject_text, | ||
) | ||
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject) | ||
assert dist.metadata.license == license | ||
assert dist.metadata.license_expression == license_expression | ||
pkg_file = tmp_path / "PKG-FILE" | ||
with open(pkg_file, "w", encoding="utf-8") as fh: | ||
dist.metadata.write_pkg_file(fh) | ||
content = pkg_file.read_text(encoding="utf-8") | ||
assert content_str in content | ||
|
||
|
||
class TestLicenseFiles: | ||
# TODO: After PEP 639 is accepted, we have to move the license-files | ||
# to the `project` table instead of `tool.setuptools` | ||
|