Skip to content

How can I specify differing sets of dependency extras for each of my project's extras? #834

@kurtiss

Description

@kurtiss
  • 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.

Question

How can I specify differing sets of dependency extras for each of my project's extras? This is something that is relatively trivial to do with setup.py. To clarify, I would like to be able to specify the following dependency graph:

myproject[feature-a] depends on [dependency-one, dependency-two[feature-a]]
myproject[feature-b] depends on [dependency-one, dependency-two[feature-b]]

I'll propose a couple ways that pyproject.toml might model these graphs, but the core value of these examples is to highlight an apparent deficiency with the current model.

  1. By allowing dependency aliases that specify distinct sets of extras. For example:
[tool.poetry.dependencies]
…
dependency-two-a = { git = "git+ssh://[email protected]/projects/dependency-two.git",optional = true,extras = ["feature-a"], provides="dependency-two" }
dependency-two-b = { git = "git+ssh://[email protected]/projects/dependency-two.git",optional = true,extras = ["feature-b"], provides="dependency-two" }
…

[tool.poetry.extras]
feature-a = ["dependency-one", "dependency-two-a"]
feature-b = ["dependency-one", "dependency-two-b"]
  1. By treating the set of extras in the dependencies section as a superset that can be further filtered down when the dependency is referenced in the extras section. For example:
[tool.poetry.dependencies]
…
dependency-two = { git = "git+ssh://[email protected]/projects/dependency-two.git",optional = true,extras = ["feature-a", "feature-b"]}
…

[tool.poetry.extras]
feature-a = ["dependency-one", "dependency-two[feature-a]"]
feature-b = ["dependency-one", "dependency-two[feature-b]"]

Thanks for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFeature requests/implementations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions