-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Feature Proposal: PEP 735 "Dependency Groups" Support #12963
Comments
Some questions around the UI. How would something like How will the flag work with multiple requirements? If I do Basically, I don't think we have an existing flag that works like I'd expect this one to, which might be a usability problem. |
I'd consider pip the wrong place for managing this in a normal way IMHO it's different enough from normal install that it warrants a distinct command to install dependency groups of a specific source folder Tools like hatch, rye and poetry should be the place of closer integration |
I am a bit concerned about meeting the target use cases for the PEP without pip support. It would be possible, but the user experience is worse in several cases.
That may be, but I see the feature as similar to
I think the answer here is "and" not "or". Dependency Groups will have the greatest positive impact if they are supported by installers, environment managers, and build backends. I've started with pip and setuptools. Perhaps this is a strategy mistake and I should begin from younger tools like flit. Before I dive into Paul's specific scenarios, I want to start from the high level concern, make sure I understand it, and consider whether or not the UX I proposed is correct.
Is the issue that this is expected to expand to a set of requirements, whereas I'm trying to understand if the issue would be mitigated by making the toml file explicit, e.g., |
I believe the proposed installation ux clearly shows my 3rd point |
I think the problem for me was that it wasn't clear that you're proposing that
If I understand, you're proposing to add a new form here:
This would look in a
That was incorrect, we do, it's There's some background information available in #8049. The conclusion there was that we rejected the feature request, but dependency groups are much more specific, and will be standards-based, so I think it's within scope for pip to support them. Also, there may be some edge cases that won't work, because requirements files are much richer than dependency groups. For example, |
Strong -1 on me for allowing anything but "read dependency groups from |
So one of the repos I work with is a messy monorepo, in that repo we would never put a This has never been a problem because front end and utility tools, like pip, pre-commit, linters, formatters, etc. allow you to specify where you want the configuration / requirements to come from. And backend tools that do not allow this are generally not suitable for the repo anyway i.e. we never want to build a package in the root of the repo. Were pip to use this as a "requirements-like install file but with structured options" it would be a departure from pip's current approach to allow the user to specify the path of the requirements file or constraints file, and other front end tools in general. If you don't consider "messy monorepo" as a valid use case, fair enough, but we're not trying to build a package from it, so it would be annoying for frontend tools, that are not project management tools, to say how we should structure our project. That said, this isn’t a hill I want to die on, just want to give an alternative view point. |
I think "messy monorepo" is a valid use-case to consider for If I'm not strictly against something like I'm not sure if I should open a draft PR or not at this stage? I can add a |
Update: PEP 735 has been accepted 🎉 |
Fantastic. We have some good use cases for those in Airflow and once |
FWIW, uv has shipped dependency groups (as has tox). It would potentially be nice to mimic the CLI interface names here unless there's a reason not to. |
I refrained from taking any further action here because it wasn't clear if the pip maintainers had sufficient agreement that we should add it. I didn't want to push the issue too aggressively, but my approach may have been too hands off. I'll work this up in the form of a PR as soon as I'm able to devote the time, and can drive discussion to a clearer yes-or-no decision. In the meantime,
I don't have particularly strong feelings about what the option name should be, so I would be inclined to follow their lead and use |
Is it |
I think that using That said, maybe this is an argument against having the same UI, since users will incorrectly infer that the two do the same thing. I can just imagine the naive user tickets asking why |
Well, uv have added their to their project management CLI:
But they have not added it to their pip CLI:
Which I think is a little telling... Or maybe they're waiting for a user request or see what pip does. I don't see any mention of |
They've said that they're waiting to see what |
I like |
$ uvx uv@0.4.27 sync --help | grep group Fri Oct 25 16:52:04 2024
--no-dev Omit the development dependency group
--only-dev Only include the development dependency group
--group <GROUP> Include dependencies from the specified dependency group
--no-group <NO_GROUP> Exclude dependencies from the specified dependency group
--only-group <ONLY_GROUP> Only include dependencies from the specified dependency group (I'm one version behind, waiting on homebrew, so using uvx to check it) Ah, you are using |
Ah, good point. I think that mitigates my concern about supporting it in I'll work with
Yes, once the dust settles, I do want to pursue this idea. (Or related ideas which cover this functionality.) |
Ah yes, I see they're not exposed via Probably a cue that project semantics are not the same as install semantics and pip should choose independently of uv. |
We have some additional experience that may help here. uv already supports
In this case, we actually don't install the project itself, just the dependencies declared in the file. Generally, this is confusing to people using
I believe we added this flag for Adding support for PEP 735 looks like a very similar problem. There is no standard way to request groups in the package specifier. In hindsight, this probably should have been considered in the PEP (I do not recall seeing discussion, if there was any, please point me to it!). There's a bit more complexity here, in that pip does not support project files via
So, where do we go from here? In uv, I think we'll need to support Concretely, I'd recommend adding a
If there are no paths (e.g., I think this is the most guessable solution for users, e.g., you'd just tack on This leaves an important use-case unaddressed: installing a group without the project itself. I'm not sure what the best path forward on this is for pip. Similarly, we haven't figured out how to expose an interface for groups without a To be clear, I don't have any expectation that pip conforms to uv's interface. I do think it's in the best interest of the users to have a coherent experience across tools though. I'm hoping that our experiences and feedback from users can help inform decisions here (and vice-versa!). |
I believe this was deliberate, and in any case it's correct IMO, as allowing requirement specifiers to include dependency groups would allow projects to depend on dependency groups, which isn't possible because dependency groups aren't stored in project metadata. Requesting groups via an installer flag is the intended approach.
I don't think that's something we'd want to support, either. The This is the root of why dependency groups are a bit of an uncomfortable "fit" for pip. We very deliberately and explicitly don't require any sort of concept of "the current project" in order to use pip. But dependency groups are very much a project-oriented concept (because they are defined in the project metadata file!) But maybe that suggests a way forward here. We could add a new
Just to be clear, this is not a fully-formed idea at this point, it's just an off-the-cuff suggestion for an approach that fits better with pip's design. It will need some work to flesh it out.
In particular, I don't like this option. As you say, it doesn't offer a way to not install the project, and furthermore, it complicates things when there's multiple paths in the install command (which might not even agree on what group names mean). And it also makes local directory names special, in a way that would immediately prompt the question "why not allow reading
Agreed, and at least personally, it's not a direction I want to go in (I haven't asked the other @pypa/pip-committers their views on this). In particular, while I don't want to fall into the trap of making every detail a big design question, I also don't want a significant change in philosophy to "slip in" as part of what should be a fairly straightforward feature addition.
Thanks for that comment. And I do agree that being consistent is better for users. I think that pip and the Footnotes |
I agree. We adapted this from
Did you see I recommended this? Basically, yeah this makes sense to me. I especially like that you highlighted that there is future work that will require project awareness in pip. However, I worry that it'll be confusing for users to need a command like:
This is what led me to having There are still confusing cases where it's not clear what
I think the idea here is that we would support this for source trees, but not distributions. I don't think it'd be hard distinction to make, i.e., we won't consume parts of the
They want both 🙃 In this context, it might be fine if we infer the value of
I guess I'd say... "uv's interface" or "uv's project interface" vs "uv's pip-compatible interface". The project interface includes all of our top-level commands, though |
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:
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 directoryFor example,
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 topip
.For example, in a *nix environment, the following usage covers most cases:
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
The text was updated successfully, but these errors were encountered: