Skip to content
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

Support for optional dependency groups #179

Closed
savente93 opened this issue Jul 6, 2023 · 5 comments
Closed

Support for optional dependency groups #179

savente93 opened this issue Jul 6, 2023 · 5 comments

Comments

@savente93
Copy link

As some context around this feature request: I currently work on a project that has a plugin system, and each of the plugins have some quite heavy dependencies, so we would like a way for these plugins to install their dependencies but not have to include unnecessary ones, without having to maintain separate environment files. Our currently pyproject.toml has a table something like this:

[project.optional-dependencies]
io = [
    "s3fs",             # S3 file system
    ...
]
extra = [
    "xugrid",
    ...
]
dev = [
    "black",       # linting
    "ruff",        # linting
    ...
]
test = [
    "pytest>=2.7.3", # testing framework
    "pytest-cov",    # test coverage
    "pytest-mock",   # mocking
]
doc = [
    "nbsphinx",                     # build notebooks in docs
    ...,
    "hydromt[jupyter,extra]",       # examples are included in the docs
]
jupyter = [
    "jupyterlab",      # run examples in jupyter notebook
    ...
]

full = ["hydromt[io,extra,dev,test,doc, jupyter]"]
slim = ["hydromt[io,extra,jupyter]"]

The exact way that these groups are specified doesn't actually matter that much to me, but the idea that I'm basing all of this off is cargo and it's feature groups. For me personally this feature would consist of three components in decreasing order of importance.

  1. being able to specify which groups of dependencies are needed and have those be installed
  2. the ability for groups to reference each other (e.g. dev could require "docs" and "testing")
  3. Having some information about which groups were used in the lockfile.

In an ideal case I would also love the ability to "incrementally" up or downgrade between these configs, but I feel like that is a bit much for just one issue, so I'll open that discussion in a separate one

@baszalmstra
Copy link
Contributor

This is related to #239 as well as conda/ceps#55

@olivier-lacroix
Copy link
Contributor

This would be great.

Not quite sure how that would interact with the lockfile(s): optional dependencies do not have to be 'compatible' between each other. Would there be one lockfile per optional group?

@savente93
Copy link
Author

A lockfile is a record of exactly which versions have been installed right? In that case I think the simplest option for both users and the devs is that a lockfile doesn't really need these notions. There is the "the lockfile" of whatever was installed. If projects want lock files per group (or subset thereof) it should be on them to generate and commit them. I beleive this is how cargo does it too? (though don't quote me on that) Honestly I'm inclined to say "do whatever cargo does" because that's seen quite some use already, so they would have some experience in this already I assume

@paugier
Copy link

paugier commented Jan 9, 2024

PDM uses both [project.optional-dependencies] (https://peps.python.org/pep-0621/#dependencies-optional-dependencies) and [tool.pdm.dev-dependencies] (which are both useful) and a lockfile taking into account these groups of optional dependencies.

@pavelzw
Copy link
Contributor

pavelzw commented Mar 19, 2024

This is fixed now with the pixi multi env feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants