python-poetry / python-poetry/poetry

Specify distinct dependency extras for distinct poetry project extras!

Open
#3,913 2 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

Currently, adding an optional dependency to have in extras only allows one dependency per project. The issue here is that I may have two extras for my projects, say distributed and server, with ray and ray[serve] as dependencies respectively.

When I poetry add ray we modify the dependencies as

[tool.poetry.dependencies]
python = "^3.8"
ray = {version = "^1.2.0", optional = true}

and then when I add ray[serve] on top it modifies the dependencies as

[tool.poetry.dependencies]
python = "^3.8"
ray = {extras = ["serve"], version = "^1.2.0", optional = true}

getting rid of the default ray. Thus, I don't see any way to have something like

[tool.poetry.extras]
distributed = ["ray"]
server = ["ray[serve]"]

without also installing ray[serve] as part of the distributed extra!

I cannot think of any reason this would be desired behavior to not allow treating dependency extras as separate. While I haven't spent a great deal of time thinking about a design for a proposed solution, the above seems reasonable to me (that when specified in extras, a reference to ray does not include ray[serve] by default).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no implementation files or tests; start by tracing Poetry's dependency and project-extra handling for the two pyproject.toml examples. Done means distinct project extras can reference the same dependency with and without its dependency extra, without the broader dependency selection being included implicitly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.