summaryrefslogtreecommitdiff
path: root/src/tox
diff options
context:
space:
mode:
Diffstat (limited to 'src/tox')
-rw-r--r--src/tox/tox_env/python/virtual_env/package/pyproject.py16
-rw-r--r--src/tox/tox_env/python/virtual_env/package/util.py9
2 files changed, 19 insertions, 6 deletions
diff --git a/src/tox/tox_env/python/virtual_env/package/pyproject.py b/src/tox/tox_env/python/virtual_env/package/pyproject.py
index 77508732..2e3e61b1 100644
--- a/src/tox/tox_env/python/virtual_env/package/pyproject.py
+++ b/src/tox/tox_env/python/virtual_env/package/pyproject.py
@@ -33,7 +33,7 @@ from tox.tox_env.runner import RunToxEnv
from tox.util.file_view import create_session_view
from ..api import VirtualEnv
-from .util import dependencies_with_extras
+from .util import dependencies_with_extras, dependencies_with_extras_from_markers
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from importlib.metadata import Distribution, PathDistribution
@@ -253,11 +253,17 @@ class Pep517VirtualEnvPackager(PythonPackageToxEnv, VirtualEnv):
if dynamic == "dependencies" or (extras and dynamic == "optional-dependencies"):
return None # if any dependencies are dynamic we can just calculate all dynamically
- deps: list[Requirement] = [Requirement(i) for i in project.get("dependencies", [])]
+ deps_with_markers: list[tuple[Requirement, set[str | None]]] = [
+ (Requirement(i), {None}) for i in project.get("dependencies", [])
+ ]
optional_deps = project.get("optional-dependencies", {})
- for extra in extras:
- deps.extend(Requirement(i) for i in optional_deps.get(extra, []))
- return deps
+ for extra, reqs in optional_deps.items():
+ deps_with_markers.extend((Requirement(req), {extra}) for req in (reqs or []))
+ return dependencies_with_extras_from_markers(
+ deps_with_markers=deps_with_markers,
+ extras=extras,
+ package_name=project.get("name", "."),
+ )
def _load_deps_from_built_metadata(self, for_env: EnvConfigSet) -> list[Requirement]:
# dependencies might depend on the python environment we're running in => if we build a wheel use that env
diff --git a/src/tox/tox_env/python/virtual_env/package/util.py b/src/tox/tox_env/python/virtual_env/package/util.py
index 948de48c..603f93ed 100644
--- a/src/tox/tox_env/python/virtual_env/package/util.py
+++ b/src/tox/tox_env/python/virtual_env/package/util.py
@@ -8,7 +8,14 @@ from packaging.requirements import Requirement
def dependencies_with_extras(deps: list[Requirement], extras: set[str], package_name: str) -> list[Requirement]:
- deps_with_markers = extract_extra_markers(deps)
+ return dependencies_with_extras_from_markers(extract_extra_markers(deps), extras, package_name)
+
+
+def dependencies_with_extras_from_markers(
+ deps_with_markers: list[tuple[Requirement, set[str | None]]],
+ extras: set[str],
+ package_name: str,
+) -> list[Requirement]:
result: list[Requirement] = []
found: set[str] = set()
todo: set[str | None] = extras | {None}