Exposing a dependency's extra as main packages extra #7773
Replies: 1 comment
|
For Poetry 2.x, you can express this with the standard [project]
name = "extra-forwarding-example"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = ["A>=1,<2"]
[project.optional-dependencies]
with-a = ["A[a]>=1,<2"]
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"Here So a consumer requesting If the extra needs a tighter version constraint, put that constraint in its requirement, keeping it compatible with the base requirement. They are combined when the extra is selected; this does not install two different versions of Your first attempt uses the legacy I checked the exact TOML with poetry-core 2.2.1 on Python 3.14.6: generated References: optional dependencies, dependency extras and markers. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm developing a package, that depends on package A. Package A provides an extra: a that I would like to expose as my own extra. How would I go about it?
Here are some options I explored:
Option 1: Using
[]in extra specificationApart from being a bit confusing and not explicit/expressive enough in my opinion (what if I want a different version of A[a], etc.), this
gives me:
Option 2: Naming the A dependency different based on whether it includes the extra
gives me
Option 3: Using groups
This doesn't seem to be supported (see discussion here) but looks like what would solve the issue. Additionally, if I understand this comment, extras need to be specified in the main dependency group which in my case leads to naming issues.
Is there something I'm missing?
All reactions