|
Note I've used AI to organize and format everything properly in the text below, but this is a real issue I've encountered. I'm trying to determine whether this is a Poetry bug or whether I'm misunderstanding how dependency markers and extras are evaluated. Environment
Original issueIn a larger project, my dependency is: [project]
dependencies = [
"sqlalchemy[asyncio]>=2.0.45,<3.0.0",
]Running the application resulted in: Checking the environment showed that $ poetry run pip show greenlet
WARNING: Package(s) not found: greenletAdding an explicit dependency on Initial investigationI noticed SQLAlchemy publishes this dependency metadata: On my machine: $ python3 -c "import platform; print(platform.machine())"
arm64So initially I suspected the missing Minimal reproductionTo isolate the issue, I created a fresh project.
[project]
name = "poetry-greenlet-repro"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"sqlalchemy[asyncio]>=2.0.51,<3",
]
[tool.poetry]
package-mode = false
[build-system]
requires = ["poetry-core>=2.0.0,<3"]
build-backend = "poetry.core.masonry.api"Then: poetry env use python3.12
poetry lock
poetry installThe install output is: Notice that Verifying the environment
$ poetry run pip show greenlet
WARNING: Package(s) not found: greenlet$ poetry run python -c "import greenlet"
ModuleNotFoundError: No module named 'greenlet'However, Poetry still resolves greenlet$ poetry debug resolve
Resolution results:
greenlet 3.5.4
typing-extensions 4.16.0
sqlalchemy 2.0.51Poetry also reports greenlet as a dependency$ poetry show sqlalchemy
name : sqlalchemy
version : 2.0.51
dependencies
- greenlet >=1
- typing-extensions >=4.6.0Dependency tree: $ poetry show sqlalchemy --tree
sqlalchemy 2.0.51
├── greenlet >=1
└── typing-extensions >=4.6.0Or: $ poetry show --tree --why greenlet
sqlalchemy
└── greenlet >=1Installed SQLAlchemy metadataThe metadata inside the installed wheel contains: $ poetry run python - <<'PY'
from importlib.metadata import metadata
for req in metadata("SQLAlchemy").get_all("Requires-Dist"):
if "greenlet" in req:
print(req)
PYOutput: Verbose installRunning poetry install -vvvdoes not mention Searching the verbose output: poetry install -vvv 2>&1 | grep -i greenletonly prints There is no indication that Poetry considered, installed, or skipped Platform informationThe project is definitely running on Apple Silicon: $ poetry run python -c "import platform; print(platform.machine())"
arm64
Why I'm confusedThese observations seem contradictory:
Related issueWhile investigating, I found this SQLAlchemy issue: A maintainer commented that this appeared to be a Poetry issue involving dependencies listed in extras with different markers. That seems similar to what I'm seeing, although I'm not sure if it's the same underlying problem. Questions
|
Replies: 1 comment
|
Hi @mallhok! I'm Dosu and I'm helping the Python Poetry team. This is a confirmed bug, not a misunderstanding on your part. It was recently reported in #10910 with the exact same scenario — Root cause: When SQLAlchemy declares Why The fix has been merged in poetry-core#943, which corrects What you can do now: Until a Poetry release ships with the updated To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
Hi @mallhok! I'm Dosu and I'm helping the Python Poetry team.
This is a confirmed bug, not a misunderstanding on your part. It was recently reported in #10910 with the exact same scenario —
sqlalchemy[asyncio]on Mac Darwin arm64 failing to installgreenlet[1].Root cause: When SQLAlchemy declares
greenletwith two separate conditions — a platform marker (platform_machine == "aarch64" or ...) and an extras marker (extra == "asyncio") — Poetry's marker exclusion logic inpoetry-coreincorrectly handles the union of these markers. When it strips theextra == "asyncio"marker during lock file generation, instead of collapsing the result to "always install," it keeps only the platform marke…