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

Poetry Dependency Resolution Issue while Dependency extras with source #8796

Closed
4 tasks done
lucemia opened this issue Dec 15, 2023 · 3 comments
Closed
4 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@lucemia
Copy link
Contributor

lucemia commented Dec 15, 2023

  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

When using poetry update to resolve dependencies, Poetry treats dependencies without extras as distinct entities, leading to unexpected behavior. This issue can be illustrated as follows:

  1. In repo-a's pyproject.toml, the definition for the source of private-package-a[extra-a] is set to "source-a".
  2. repo A has a dependency on pivate-pacakge-b, and pivate-pacakge-b in turn depends on private-package-a (without extra).
  3. However, repo-a's pyproject.toml does not define the source for private-package-a without any extras.

The problem arises when Poetry encounters this configuration. It raises an error: "Package private-package-a (*) not found." The issue here is that package source keys are not inherited by their dependencies when extras are involved, which is unexpected behavior.

repo-a's pyproject.toml

[tool.poetry]
name = "repo-a"
version = "0.0.0"
description = ""
[tool.poetry.dependencies]
private-package-a = { version = "*", source = "source-a", extras = ["extra-a"] }
private-package-b = { version = "*", source = "source-a" }
[[tool.poetry.source]]
name = "source-a"
priority = "explicit"

private-package-b's pyproject.toml

[tool.poetry]
name = "private-package-b"
version = "0.0.0"
description = ""
[tool.poetry.dependencies]
private-package-a = { version = "*", source = "source-a" }
[[tool.poetry.source]]
name = "source-a"
priority = "explicit"

Expected Behavior:

  • Is it considered valid in Poetry to define a package with multiple sources (if they have different extras)? If not, implementing a validation check could be beneficial.

Temporary Workaround:

To work around this issue, you can temporarily declare the source for the dependency without extras in another group to avoid encountering the error.

[tool.poetry]
name = "repo-a"
version = "0.0.0"
description = ""

[tool.poetry.dependencies]
private-package-a = { version = "*", source = "source-a", extras = ["extra-a"] }
private-package-b = { version = "*", source = "source-a" }

[tool.poetry.group.service.dependencies]
private-package-a = { version = "*", source = "source-a" } # add this line

[[tool.poetry.source]]
name = "source-a"
priority = "explicit"
@lucemia lucemia added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 15, 2023
@dimbleby
Copy link
Contributor

Duplicate #8614 please close

@lucemia
Copy link
Contributor Author

lucemia commented Dec 15, 2023

@dimbleby sorry for bothering

@lucemia lucemia closed this as completed Dec 15, 2023
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
@abn abn removed the status/triage This issue needs to be triaged label Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants