summaryrefslogtreecommitdiff
path: root/setuptools/tests/config
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-03-27 15:40:57 +0100
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-03-27 15:57:25 +0100
commitd0ee3e4944245db6b37cba2b3335dcacc2d3e6f6 (patch)
tree42f5a188522af0ff6dbf614440a99e7de145ab7c /setuptools/tests/config
parent91f9960726a7a73f1009ec3adeace04f4dd6c66c (diff)
downloadpython-setuptools-git-d0ee3e4944245db6b37cba2b3335dcacc2d3e6f6.tar.gz
Ensure pyproject.toml does not break dynamic install_requires
Diffstat (limited to 'setuptools/tests/config')
-rw-r--r--setuptools/tests/config/test_apply_pyprojecttoml.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py
index c09ff3e6..a88bc1ec 100644
--- a/setuptools/tests/config/test_apply_pyprojecttoml.py
+++ b/setuptools/tests/config/test_apply_pyprojecttoml.py
@@ -15,6 +15,7 @@ from setuptools.dist import Distribution
from setuptools.config import setupcfg, pyprojecttoml
from setuptools.config import expand
from setuptools.config._apply_pyprojecttoml import _WouldIgnoreField
+from setuptools.command.egg_info import write_requirements
EXAMPLES = (Path(__file__).parent / "setupcfg_examples.txt").read_text()
@@ -207,12 +208,12 @@ def test_license_and_license_files(tmp_path):
class TestPresetField:
- def pyproject(self, tmp_path, dynamic):
+ def pyproject(self, tmp_path, dynamic, extra_content=""):
content = f"[project]\nname = 'proj'\ndynamic = {dynamic!r}\n"
if "version" not in dynamic:
content += "version = '42'\n"
file = tmp_path / "pyproject.toml"
- file.write_text(content, encoding="utf-8")
+ file.write_text(content + extra_content, encoding="utf-8")
return file
@pytest.mark.parametrize(
@@ -250,6 +251,28 @@ class TestPresetField:
dist_value = getattr(dist, attr, None) or getattr(dist.metadata, attr, object())
assert dist_value == value
+ def test_optional_dependencies_dont_remove_env_markers(self, tmp_path):
+ """
+ Internally setuptools converts dependencies with markers to "extras".
+ If ``install_requires`` is given by ``setup.py``, we have to ensure that
+ applying ``optional-dependencies`` does not overwrite the mandatory
+ dependencies with markers (see #3204).
+ """
+ # If setuptools replace its internal mechanism that uses `requires.txt`
+ # this test has to be rewritten to adapt accordingly
+ extra = "\n[project.optional-dependencies]\nfoo = ['bar>1']\n"
+ pyproject = self.pyproject(tmp_path, ["dependencies"], extra)
+ install_req = ['importlib-resources (>=3.0.0) ; python_version < "3.7"']
+ dist = makedist(tmp_path, install_requires=install_req)
+ dist = pyprojecttoml.apply_configuration(dist, pyproject)
+ assert "foo" in dist.extras_require
+ assert ':python_version < "3.7"' in dist.extras_require
+ egg_info = dist.get_command_obj("egg_info")
+ write_requirements(egg_info, tmp_path, tmp_path / "requires.txt")
+ reqs = (tmp_path / "requires.txt").read_text(encoding="utf-8")
+ assert "importlib-resources" in reqs
+ assert "bar" in reqs
+
# --- Auxiliary Functions ---