Description
What's the problem this feature will solve?
"Dependency Groups" are proposed in PEP 735 with a variety of target use cases.
In particular, the --only-deps
use cases are explicitly a target for this PEP, but additional cases are listed and relevant.
Describe the solution you'd like
As the PEP author, I would like to start discussing what form, in terms of interface and implementation, pip
support would take.
I would like to agree on a potential implementation path, implement it in a draft PR, and leave it pending until the PEP is accepted.
My proposal is:
- a variant of the DependencyGroupResolver I wrote moves in-tree here, along with appropriate unit tests
- a new CLI option is added to
pip install
,--dependency-groups
, which takes a comma-delimited list of group names and attempts to resolve and install all of them frompyproject.toml
in the current working directory
For example,
# in pyproject.toml
[dependency-groups]
test = ["pytest"]
typing = ["pyright"]
# on the CLI
pip install --dependency-groups test,typing
# equivalent to
pip install pytest pyright
Would the pip
maintainers be amenable to this addition? Is there an alternative, similar strategy which I could implement?
Alternative Solutions
If pip
does not gain support for Dependency Groups, it is possible to workaround the gap.
Primarily, external tooling like dependency-groups
can be used to resolve groups and pass them to pip
.
For example, in a *nix environment, the following usage covers most cases:
groups=$(python -m dependency_groups pytest typing | tr '\n' ' ')
pip install $groups
However, such usages will always be workarounds. pip
support provides a superior developer experience.
Additional context
PEP 735 is in Draft, and will be submitted soon. At time of writing, it is not final or accepted, but no further changes to the contents are planned.
Code of Conduct
- I agree to follow the PSF Code of Conduct.