-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Possibility to mark dependencies as dev-only that don’t go into package metadata #754
Comments
what about a subcommand that let's you install the dependencies of a given environment into the currently active environment? i assume that you want to work with these packages in an interactive shell. b/c everything else can be done with environments as they are designed and implemented, is my impression. |
What's the reason for avoiding Hatch environments? If someone else is working on your project, they'll need Hatch on their system one way or another, so I don't see the benefit in avoiding them in favor of a A dev-only optional dependency group seems more "standard-bending" than just using a Hatch environment, because the former actually changes the behavior of a standard feature, while the latter is a different thing altogether. The PDM dev-only dependencies are morally identical to (and less flexible than) having extra dependencies in a Hatch environment. It is reasonable to offer |
Official standard for this is PEP 735 – Dependency Groups in pyproject.toml, which was accepted on October 10, 2024 |
okay, so beside an implementation, hatch needs to define how dependency groups can be referenced in for environments. i'm proposing two variants to get the discussion started. one proposal would allow inclusion of references that are marked with an [dependency-groups]
stubs = ["types-lxml", "types-beautifulsoup4"]
[tool.hatch.envs.mypy]
dependencies = [
"mypy",
"@stubs"
] the only rationale for the the other proposal introduces a new key for that table: [dependency-groups]
stubs = ["types-lxml", "types-beautifulsoup4"]
[tool.hatch.envs.mypy]
dependencies = [
"mypy",
]
dependency-groups = [
"stubs"
] of these two i personally prefer the latter because it tells readers directly what is being referenced. |
PEP-735 specifies how to include a dependency group in another dependency group. We could use the same syntax: [dependency-groups]
stubs = ["types-lxml", "types-beautifulsoup4"]
[tool.hatch.envs.mypy]
dependencies = [
"mypy",
{include-group = "stubs"},
] |
i like the lexical re-use, but there's no need for nesting in this case, thus: [dependency-groups]
stubs = ["types-lxml", "types-beautifulsoup4"]
[tool.hatch.envs.mypy]
dependencies = [
"mypy",
]
include-group = [
"stubs",
] but then the singular form is unfortunate. |
Either syntax works. But, is there not a common standard for the pyproject.toml or it depends on the build / package tool? Are there any pros to using the PEP735 or cons not using it? That said, having the functionality in hatch is more important. |
Closest analogy that is currently supported by Hatch would be features, which allows an environment to specify which of the project's optional dependencies/extras should be installed, which works like [project.optional-dependencies]
foobar = ["foo", "bar >= 2.0"]
[tool.hatch.envs.example]
features = ["foobar"] Following that precedent would look like @funkyfuture's preferred syntax (with the caveat that there could be some bikeshedding over what name to use as the key in the table) Since the value should be an array of strings, I would say that the key should be plural, and it seems like in general nouns are preferred over verbs. The simplest answer to me seems to be to just call it [dependency-groups]
stubs = ["types-lxml", "types-beautifulsoup4"]
[tool.hatch.envs.mypy]
dependencies = [
"mypy",
]
dependency-groups = [
"stubs"
] |
that also aligns well with the
yes, that's the general linguistic understanding.
the standard tells us how these groupings are to be defined, not how they should be referred to in hatch-specific configuration data.
that is false in its division of design and implementation:
|
Ok. The fragmention of pyproject.toml seems unnecessary, but if only the functionality and not the syntax is defined in the standard then that's it.
I think you misinterpreted me here. I can personally be a pedantic (or fanatic or whatever one wants to call it) about naming things for the reasons that you mentioned among other things. But, the functionality is more important than naming - not saying that naming is not important. Why? Let's take it to the extreme and play devil's advocate, the dwelling on naming will continue for all eternity what do you think that the user experience will be then? |
I'm having a hard time reading the state of this feature. Is there something that can be contributed to assist specification or implementation? Or is it rather something you want to tackle in core devs but it's not at the top of the list at the moment? |
i wouldn't know of other core devs than ofek. myself has other priorities. |
I like using optional dependencies like
tests
ordocs
for local development.However, it has the annoying side-effect of putting that into package metadata which make it look like attrs depends on some wild stuff.
It would be nice to have dev-only dependency groups and my recent foray into PDM showed me there’s precedent for that: https://pdm.fming.dev/latest/usage/dependency/#add-development-only-dependencies
Syntax is the same, just different key:
FWIW, I’d be perfectly content with something like this which is less standard-bending:
I realize there’s certain overlap with hatch environments, but I don’t want to break the Python-standard ways of installing packages. At least for now (fact aside that I can’t use them for now :))
The text was updated successfully, but these errors were encountered: