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

Extras dependencies listed in groups do not raise error. #9790

Open
originalrkk opened this issue Oct 22, 2024 · 2 comments
Open

Extras dependencies listed in groups do not raise error. #9790

originalrkk opened this issue Oct 22, 2024 · 2 comments
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@originalrkk
Copy link

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 originalrkk added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 22, 2024
@dimbleby
Copy link
Contributor

The code you want already exists. Try poetry check.

@originalrkk
Copy link
Author

originalrkk commented Oct 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants