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 lock creates wrong lockfile for dependencies from custom source with extras - while poetry add works correctly #8997

Closed
4 tasks done
vkuhnde opened this issue Feb 20, 2024 · 3 comments
Labels
kind/bug Something isn't working as expected

Comments

@vkuhnde
Copy link

vkuhnde commented Feb 20, 2024

  • Poetry version: 1.7.1
  • Python version: 3.10.12 (with 3.11.1 in that specific virtualenv)
  • OS version and name: Ubuntu 22.04.3 LTS in WSL2 on Windows 11 Pro 23H2
  • pyproject.toml:
[tool.poetry]
name = "my_package"
version = "0.0.1"
description = "..."
readme = "README.md"
packages = [{ include = "my_package" }]

[[tool.poetry.source]]
name = "my-source"
url = "https://my.pypi.source/packages/pypi/simple"
priority = "explicit"

[tool.poetry.dependencies]
python = "~3.11.0"
my-lib = { version = "1.2.3", extras=["all"], source = "my-source" }

[build-system]
requires = ["poetry-core^1.0.0"]
build-backend = "poetry.core.masonry.api"
  • 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

I ran across an issue when specifying a dependency that has a custom source and some extras to be installed.

poetry add --source "my-source" "my-lib[all]==1.2.3" works correctly. The generated poetry.lock is also correct and can be used to recreate the environment.

But, whenever I try to run poetry lock afterwards, the poetry.lock breaks in a way that makes poetry install fail. poetry lock && poetry install works without any issues if the dependency is defined without extras, i.e.,:

my-lib = { version = "1.2.3", source = "my-source" }

But, whenever extras are specified for installation (no matter which ones or how many), it fails. The git diff shows, that poetry lock adds the specified packages

[package.dependencies]
+ flask = {version = ">=1.0.2", optional = true, markers = "python_version >= \"3.7\" and python_version < \"4.0\" and (extra == \"flask\" or extra == \"all\")"}

but it also removes the package extras and source section (which are present after running above poetry add command and after running poetry lock when there are no extras specified for my-lib):

- [package.extras]
- all = ["flask (>=1.0.2)", "flask (>=1.0.2,<2.1.0)", "redis[hiredis] (>=4.0.2,<5.0.0)"]
- flask = ["flask (>=1.0.2)", "flask (>=1.0.2,<2.1.0)"]
- redis = ["redis[hiredis] (>=4.0.2,<5.0.0)"]
-
- [package.source]
- type = "legacy"
- url = "https://my.pypi.source/packages/pypi/simple"
- reference = "my-source"

On poetry install --all-extras this leads to:

Installing dependencies from lock file

Repository "my-source" does not exist.

with an IndexError in poetry/repositories/repository_pool.py:136 when running with -vvv. But I guess, the error isn't really here but in the previous poetry lock command.

@vkuhnde vkuhnde added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Feb 20, 2024
@dimbleby
Copy link
Contributor

probably duplicate #8614 or #8928 I guess, please try with the master branch

@vkuhnde
Copy link
Author

vkuhnde commented Feb 20, 2024

Works :)

Sorry, I didn't find these issues.

@vkuhnde vkuhnde closed this as completed Feb 20, 2024
@abn abn removed the status/triage This issue needs to be triaged label Mar 2, 2024
Copy link

github-actions bot commented Apr 2, 2024

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 Apr 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