-
-
Notifications
You must be signed in to change notification settings - Fork 348
Hatch environments support PEP735 dependency-groups #1922
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
base: master
Are you sure you want to change the base?
Conversation
f987adb to
ad721e5
Compare
funkyfuture
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for your effort on this. i left a few notes regarding the user documentation and hope to find some time soon for a deeper look.
maybe the PA's usage guide reg. the dependency groups could also be linked somewhere: https://packaging.python.org/en/latest/specifications/dependency-groups/
| [tool.hatch.envs.test] | ||
| dependency-groups = ["test"] | ||
|
|
||
| [tool.hatch.envs.lint] | ||
| dependency-groups = ["lint"] | ||
|
|
||
| [tool.hatch.envs.dev] | ||
| dependency-groups = ["dev"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can imagine that a completely reflected use-case would be preferable here. i don't know the current affairs reg. user documentation guidelines, maybe @lwasser has some advice.
docs/config/environment/advanced.md
Outdated
| dependencies = [ | ||
| "coverage[toml]>=7.0.0", | ||
| ] | ||
| # Project dependencies will be included if not skip-install and in dev-mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't really get what this wants to tell me; it seems to be suited for a sentence or two outside the example snippet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll remove it. The point I was trying to make is that the project.dependencies (in this example, requests) will be included in the environment if the environment is not configured with "skip-install = true" or "dev-mode = false" but it's just confusing as-is.
docs/config/environment/overview.md
Outdated
| !!! note | ||
| Unlike features which affect how the project itself is installed, dependency groups are separate dependencies that are installed alongside the project. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the point here is to point out that dependency groups are no direct project dependencies, i think that aspect can be included in one of the prior paragraphs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependency groups exist to be exactly what hatch’s env dependencies are, so I don’t like the indirection of making an env refer to dependency groups to install.
I think we should do more that simply support them, we should actually integrate them: #1852 (comment)
So I propose that we change hatch to actually collect the list of defined dependency groups and merge it with the list of hatch envs (each dependency group implicitly defines a hatch env, and each hatch env implicitly installs its corresponding dependency group). @ofek should weigh in here.
Imagine: if dependency groups would have existed when designing hatch, would they be used like I propose? I think yes.
|
@ofek have you put any further thought into this? I was VERY suprised to find out that Hatch did not support this PEP and was thus incompatible with uv and pixi, as others have mentioned. I would be happy to contribute if it is labor that is blocking this; if it's more of an administration, your thoughts on whether or not this will be something that Hatch plans to support would be very appreciated! |
|
Greetings all, I want this feature very much in hatch. I'm willing to put in the necessary work like others above, but that does not seem the blocker here. In any case, please let us know how we can contribute. |
|
Hi friends 👋🏻 it would be really helpful to include this PR in a future release if possible! We are using both development and optional dependencies in our packaging template. Being able to define dependencies and development devs in a standard TOML format that is not Hatch specific, but then use those in Hatch environments, would make the user experience much simpler and smoother as they learn about and use dependencies! |
|
I have some free time to work on this this week. It seems like this hasn't had any sort of resolution. I personally am a fan of the current implementation, but feel free to weigh in. I think it would be great to get this merged. |
|
Please describe the current implementation at a high level as well as a brief description of the comment you mentioned. This needs to be rebased as well. I plan to merge this by Monday right after #2073. |
Explicit is better than implicit. I do not think it is the right approach to make these implicit mappings. Implicit mappings like this become brittle over time and prone to breakages from changes. |
7482855 to
038d5bb
Compare
I fully agree with this. Additionally, I want to be able to use dependency groups much like extras/features today. That means, I want to define custom environments where I choose one or more groups of dependencies. |
|
@ofek rebased.
This PR integrates PEP 735 dependency groups into hatch environments similarly to the existing "features" (optional dependencies) implementation. Users can specify an array of dependency groups to compose requirements for a hatch environment.
@flying-sheep was advocating for an alternate behavior where dependency groups would be treated as de facto hatch environments. For example, a |
|
I’m totally fine if you don’t go this route. I get now that some dependency groups might only exist as a building block for others (which in turn define a full environment for some purpose), and there is no way to know which are which, so automatically defining a hatch env for every group doesn’t make sense. |
|
@ofek these changes look good to me. I think once the branch conflicts resolution is done we can merge this as well and maybe release this and workspace environments at the same time. Thanks everyone for the patience while Ofek and I worked through the PR for workspace environments! |
038d5bb to
7e6f5f4
Compare
7e6f5f4 to
4195b61
Compare
Co-authored-by: Leah Wasser <[email protected]>
4195b61 to
c7cc067
Compare
|
@ofek this is up-to-date |
Closes #754
Closes #1852