diff --git a/src/poetry/core/factory.py b/src/poetry/core/factory.py index b47eb294c..98e44631b 100644 --- a/src/poetry/core/factory.py +++ b/src/poetry/core/factory.py @@ -186,8 +186,6 @@ def configure_package( dep.in_extras.append(extra_name) package.extras[extra_name].append(dep) - break - if "build" in config: build = config["build"] if not isinstance(build, dict): diff --git a/tests/fixtures/project_with_markers_and_extras/project/__init__.py b/tests/fixtures/project_with_markers_and_extras/project/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/fixtures/project_with_markers_and_extras/pyproject.toml b/tests/fixtures/project_with_markers_and_extras/pyproject.toml new file mode 100644 index 000000000..a945b077c --- /dev/null +++ b/tests/fixtures/project_with_markers_and_extras/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "project-with-markers-and-extras" +version = "1.2.3" +description = "This is a description" +authors = ["Your Name "] +license = "MIT" + +packages = [ + {include = "project"} +] + +[tool.poetry.dependencies] +python = "*" +orjson = [ + { url = "https://example/location/orjson-3.8.0-cp310-cp310-manylinux_2_28_x86_64.whl", platform = "linux", optional = true }, + { url = "https://example/location/orjson-3.8.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", platform = "darwin", optional = true } +] + +[tool.poetry.extras] +all = ["orjson"] diff --git a/tests/test_factory.py b/tests/test_factory.py index cc985a665..9a8385dd1 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -8,9 +8,11 @@ import pytest from poetry.core.factory import Factory +from poetry.core.packages.url_dependency import URLDependency from poetry.core.packages.vcs_dependency import VCSDependency from poetry.core.semver.helpers import parse_constraint from poetry.core.toml import TOMLFile +from poetry.core.version.markers import SingleMarker if TYPE_CHECKING: @@ -323,6 +325,26 @@ def test_create_poetry_with_groups_and_explicit_main() -> None: } +def test_create_poetry_with_markers_and_extras() -> None: + poetry = Factory().create_poetry(fixtures_dir / "project_with_markers_and_extras") + + package = poetry.package + dependencies = package.requires + extras = package.extras + + assert len(dependencies) == 2 + assert {dependency.name for dependency in dependencies} == {"orjson"} + assert set(extras["all"]) == set(dependencies) + for dependency in dependencies: + assert dependency.in_extras == ["all"] + assert isinstance(dependency, URLDependency) + assert isinstance(dependency.marker, SingleMarker) + assert dependency.marker.name == "sys_platform" + assert dependency.marker.value == ( + "darwin" if "macosx" in dependency.url else "linux" + ) + + @pytest.mark.parametrize( "constraint, exp_python, exp_marker", [