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 does not install a non-optional package from lock file #9636

Closed
rgareev opened this issue Aug 16, 2024 · 3 comments · Fixed by #9700
Closed

Poetry does not install a non-optional package from lock file #9636

rgareev opened this issue Aug 16, 2024 · 3 comments · Fixed by #9700
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@rgareev
Copy link

rgareev commented Aug 16, 2024

Description

Using pyproject.toml like this:

[tool.poetry]
name = "poetry-sandbox"
version = "0.1.0"
description = ""
authors = ["rinaldv"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
burr = {extras = ["tracking-client-s3", "tracking-server-s3", "cli"], version = "^0", allow-prereleases = true }

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Use poetry lock to generate the lock file (see in attachments, poetry.lock). Notice that it contains the following snippet about non-optional requests package:

[[package]]
name = "requests"
version = "2.32.3"
description = "Python HTTP for Humans."
optional = false
python-versions = ">=3.8"
files = [
    {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"},
    {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"},
]

[package.dependencies]
certifi = ">=2017.4.17"
charset-normalizer = ">=2,<4"
idna = ">=2.5,<4"
urllib3 = ">=1.21.1,<3"

[package.extras]
socks = ["PySocks (>=1.5.6,!=1.5.7)"]
use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]

[[package]]
name = "s3transfer"

Do poetry install and notice that requests is not installed. Logs for -vvv are attached, see poetry-install.log.
Expected behavior - it should be installed, because it seems to be resolved this way already into the lock file, and before it was resolved as dependency for burr[cli].

@radoering mentioned in discord that this might be related to poetry#9427 and installer.re-resolve but this is reported for 1.8.3 version

Workarounds

Adding missing dependencies manually into pyproject.toml

Poetry Installation Method

pipx

Operating System

MacOS 13.6.7

Poetry Version

1.8.3

Poetry Configuration

cache-dir = "/Users/rgareev/Library/Caches/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/rgareev/Library/Caches/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

No response

Example pyproject.toml

[tool.poetry]
name = "poetry-sandbox"
version = "0.1.0"
description = ""
authors = ["rinaldv"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
burr = {extras = ["tracking-client-s3", "tracking-server-s3", "cli"], version = "^0", allow-prereleases = true }

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Poetry Runtime Logs

[poetry-install.log](https://github.com/user-attachments/files/16641377/poetry-install.log)
@rgareev rgareev added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 16, 2024
@radoering
Copy link
Member

@radoering mentioned in discord that this might be related to poetry#9427 and installer.re-resolve but this is reported for 1.8.3 version

You misunderstood. I said that #9427 (partially) fixes this issue: If you re-lock with this PR and set poetry config installer.re-resolve false, then requests will be installed. (poetry show still does not show requests.)

@dimbleby
Copy link
Contributor

dimbleby commented Aug 16, 2024

the lockfile contains

[[package]]
name = "burr"
version = "0.27.2"
...

[package.dependencies]
...
requests = {version = "*", optional = true, markers = "extra == \"tracking-server\""}

which has indeed forgotten all about the cli extra.

this should fix I think:

diff --git a/src/poetry/puzzle/solver.py b/src/poetry/puzzle/solver.py
index 9675bc1f..9f7e5ddd 100644
--- a/src/poetry/puzzle/solver.py
+++ b/src/poetry/puzzle/solver.py
@@ -186,9 +186,7 @@ class Solver:
                             else:
                                 _dep = _package.requires[index]
                                 if _dep.marker != dep.marker:
-                                    # marker of feature package is more accurate
-                                    # because it includes relevant extras
-                                    _dep.marker = dep.marker
+                                    _package.add_dependency(dep)
             else:
                 final_packages.append(package)
                 depths.append(results[package])

dimbleby added a commit to dimbleby/poetry that referenced this issue Sep 22, 2024
dimbleby added a commit to dimbleby/poetry that referenced this issue Sep 22, 2024
radoering pushed a commit to dimbleby/poetry that referenced this issue Sep 29, 2024
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 Oct 30, 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 status/triage This issue needs to be triaged
Projects
None yet
3 participants