poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Extras dependencies listed in groups do not raise error.

Open originalrkk opened this issue 1 year ago • 2 comments

Description

Buried in the documentation is a single line:

Dependencies listed in dependency groups cannot be specified as extras.

Strictly speaking, you'd never know it, since doing so works fine in your project itself (call it mylibrary). It's only when you go to depend on mylibrary[myextra] in a downstream repo does it become clear that the extra's dependencies are missing.

At least one of poetry lock, poetry build, or poetry publish ought to complain in this case.

Workarounds

Yes, but it is time-consuming to diagnose why dependencies are missing without a careful reading of the documentation.

Poetry Installation Method

other

Operating System

Ubuntu

Poetry Version

Poetry (version 1.8.2)

Poetry Configuration

cache-dir = "/home/REDACTED/.cache/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
repositories.REDACTED.url = "REDACTED"
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"  # /home/REDACTED/.cache/pypoetry/virtualenvs
virtualenvs.prefer-active-python = true
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = false

Python Sysconfig

No response

Example pyproject.toml

mylibrary:

[tool.poetry.dependencies]
dep = "1.0.0"

[tool.poetry.group.downstream.dependencies]
# With or without optional = true:
otherdep = "2.0.0"

[tool.poetry.extras]
myextra = ["otherdep"]

downstream repo:

[tool.poetry.dependencies]
mylibrary = { version = "*", extras = ["myextra"] }
dep = "*"  # GOOD: Detects `dep` in `mylibrary`, pegged to 1.0.0 as expected.
otherdep = "*"  # BAD: Does not detect `dep` in `mylibrary[myextra]`, gets 3.0.0.


### Poetry Runtime Logs

```bash session
N/A

originalrkk avatar Oct 22 '24 23:10 originalrkk

The code you want already exists. Try poetry check.

dimbleby avatar Oct 23 '24 07:10 dimbleby

Ah, that's interesting. I could have sworn I had run that and had no errors, but I can confirm that that seems to throw the expected error now... (Thanks and sorry.) I should be correct though that this doesn't get triggered when building/publishing? It seems like it would be better to surface an error on that path rather than allow creating a package that doesn't export the right dependencies.

originalrkk avatar Oct 23 '24 13:10 originalrkk