Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extras with dependency markers #462

Merged
merged 1 commit into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file.
20 changes: 20 additions & 0 deletions tests/fixtures/project_with_markers_and_extras/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "project-with-markers-and-extras"
version = "1.2.3"
description = "This is a description"
authors = ["Your Name <[email protected]>"]
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"]
22 changes: 22 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
[
Expand Down