-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Description
Extra markers are ignored when installing from a lock file, but they are respected when re-resolving dependencies in poetry install or poetry sync.
Consider the following pyproject.toml:
[project]
name = "test"
version = "0.1.0"
description = ""
authors = []
requires-python = ">=3.12,<3.13"
dynamic = ["dependencies"]
[tool.poetry]
requires-poetry = ">=2.0"
[tool.poetry.extras]
httpx = []
[tool.poetry.dependencies]
requests = { version = "^2.31.0", markers = "extra != 'httpx'" }
httpx = { version = "^0.28.1", markers = "extra == 'httpx'" }When executing poetry lock and then poetry sync, nothing gets installed and an empty .venv is created. Below is the output of poetry -vvv sync:
(...)
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 0 installs, 0 updates, 0 removals, 5 skipped
- Installing certifi (2024.12.14): Pending...
- Installing certifi (2024.12.14): Skipped for the following reason: Not required
- Installing charset-normalizer (3.4.1): Pending...
- Installing charset-normalizer (3.4.1): Skipped for the following reason: Not required
- Installing idna (3.10): Pending...
- Installing idna (3.10): Skipped for the following reason: Not required
- Installing urllib3 (2.3.0): Pending...
- Installing urllib3 (2.3.0): Skipped for the following reason: Not required
- Installing requests (2.32.3): Pending...
- Installing requests (2.32.3): Skipped for the following reason: Not required
Installing the current project: test (0.1.0)
(...)
Output of pip list:
Package Version Editable project location
------- ------- --------------------------------------------------
pip 24.3.1
test 0.1.0 /home/k34/repos/internal/trio-cloud-search/testaco
The behavior is the same when executing poetry -vvv sync --extras httpx. This time the httpx dependencies are also considered, but ignored.
(...)
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 0 installs, 0 updates, 0 removals, 8 skipped
- Installing certifi (2024.12.14): Pending...
- Installing certifi (2024.12.14): Skipped for the following reason: Not required
- Installing h11 (0.14.0): Pending...
- Installing h11 (0.14.0): Skipped for the following reason: Not required
- Installing sniffio (1.3.1): Pending...
- Installing sniffio (1.3.1): Skipped for the following reason: Not required
- Installing typing-extensions (4.12.2): Pending...
- Installing typing-extensions (4.12.2): Skipped for the following reason: Not required
- Installing idna (3.10): Pending...
- Installing idna (3.10): Skipped for the following reason: Not required
- Installing anyio (4.8.0): Pending...
- Installing anyio (4.8.0): Skipped for the following reason: Not required
- Installing httpcore (1.0.7): Pending...
- Installing httpcore (1.0.7): Skipped for the following reason: Not required
- Installing httpx (0.28.1): Pending...
- Installing httpx (0.28.1): Skipped for the following reason: Not required
However, when enabling re-resolving, both cases work correctly:
$ POETRY_INSTALLER_RE_RESOLVE=True poetry sync
Installing dependencies from lock file
Package operations: 5 installs, 0 updates, 0 removals
- Installing certifi (2024.12.14)
- Installing charset-normalizer (3.4.1)
- Installing idna (3.10)
- Installing requests (2.32.3)
- Installing urllib3 (2.3.0)
Installing the current project: test (0.1.0)
$ POETRY_INSTALLER_RE_RESOLVE=True poetry sync --extras httpx
Installing dependencies from lock file
Package operations: 6 installs, 0 updates, 3 removals
- Removing charset-normalizer (3.4.1)
- Removing requests (2.32.3)
- Removing urllib3 (2.3.0)
- Installing anyio (4.8.0)
- Installing h11 (0.14.0)
- Installing httpcore (1.0.7)
- Installing httpx (0.28.1)
- Installing sniffio (1.3.1)
- Installing typing-extensions (4.12.2)
Installing the current project: test (0.1.0)
Workarounds
Enable re-resolving. However I am not 100% sure if this fixes all use-cases for extra markers.
Poetry Installation Method
pip
Operating System
Ubuntu 22.04.5 LTS
Poetry Version
Poetry (version 2.0.1)
Poetry Configuration
cache-dir = "/home/k34/.cache/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /home/k34/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = falsePython Sysconfig
No response
Example pyproject.toml
See description of the issue.
Poetry Runtime Logs
See description of the issue.