Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
249 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Enabled using ``file:`` for requirements in setup.cfg -- by :user:`akx` |
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 @@ | ||
Enabled using ``file:`` for dependencies and optional-dependencies in pyproject.toml -- by :user:`akx` |
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
45 changes: 38 additions & 7 deletions
45
setuptools/config/_validate_pyproject/fastjsonschema_validations.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
82 changes: 82 additions & 0 deletions
82
setuptools/tests/config/test_pyprojecttoml_dynamic_deps.py
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,82 @@ | ||
import pytest | ||
|
||
from setuptools.config.pyprojecttoml import apply_configuration | ||
from setuptools.dist import Distribution | ||
from setuptools.tests.textwrap import DALS | ||
|
||
|
||
def test_dynamic_dependencies(tmp_path): | ||
(tmp_path / "requirements.txt").write_text("six\n # comment\n") | ||
pyproject = (tmp_path / "pyproject.toml") | ||
pyproject.write_text(DALS(""" | ||
[project] | ||
name = "myproj" | ||
version = "1.0" | ||
dynamic = ["dependencies"] | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
[tool.setuptools.dynamic.dependencies] | ||
file = ["requirements.txt"] | ||
""")) | ||
dist = Distribution() | ||
dist = apply_configuration(dist, pyproject) | ||
assert dist.install_requires == ["six"] | ||
|
||
|
||
def test_dynamic_optional_dependencies(tmp_path): | ||
(tmp_path / "requirements-docs.txt").write_text("sphinx\n # comment\n") | ||
pyproject = (tmp_path / "pyproject.toml") | ||
pyproject.write_text(DALS(""" | ||
[project] | ||
name = "myproj" | ||
version = "1.0" | ||
dynamic = ["optional-dependencies"] | ||
[tool.setuptools.dynamic.optional-dependencies.docs] | ||
file = ["requirements-docs.txt"] | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
""")) | ||
dist = Distribution() | ||
dist = apply_configuration(dist, pyproject) | ||
assert dist.extras_require == {"docs": ["sphinx"]} | ||
|
||
|
||
def test_mixed_dynamic_optional_dependencies(tmp_path): | ||
""" | ||
Test that if PEP 621 was loosened to allow mixing of dynamic and static | ||
configurations in the case of fields containing sub-fields (groups), | ||
things would work out. | ||
""" | ||
(tmp_path / "requirements-images.txt").write_text("pillow~=42.0\n # comment\n") | ||
pyproject = (tmp_path / "pyproject.toml") | ||
pyproject.write_text(DALS(""" | ||
[project] | ||
name = "myproj" | ||
version = "1.0" | ||
dynamic = ["optional-dependencies"] | ||
[project.optional-dependencies] | ||
docs = ["sphinx"] | ||
[tool.setuptools.dynamic.optional-dependencies.images] | ||
file = ["requirements-images.txt"] | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
""")) | ||
# Test that the mix-and-match doesn't currently validate. | ||
with pytest.raises(ValueError, match="project.optional-dependencies"): | ||
apply_configuration(Distribution(), pyproject) | ||
|
||
# Explicitly disable the validation and try again, to see that the mix-and-match | ||
# result would be correct. | ||
dist = Distribution() | ||
dist = apply_configuration(dist, pyproject, ignore_option_errors=True) | ||
assert dist.extras_require == {"docs": ["sphinx"], "images": ["pillow~=42.0"]} |
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