-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
uv sync
always tries to resolve all optional-dependencies
#6729
Comments
This is by design. We resolve the entire project at once, but would only install the subset that's relevant. Conflicting optional dependencies are not yet supported. |
heya, yeh this is a blocker for using uv in a similar way to e.g. tox, i.e. having different optional groups, for running tests, doc builds, etc against different dependency matrices (that can potentially conflict). I guess hopefully #5632 should allow this one day but for now I'll probably stick to https://github.com/tox-dev/tox-uv (which works better for this) rather than "full-blown" uv 😅 |
We should document this in https://docs.astral.sh/uv/concepts/projects/#project-lockfile I guess we should also have an issue specifically tracking allowing conflicting extras. I'll follow up on these things. |
cheers |
To clarify, the main use case, is that I want to be able to do something like this: |
I was bit by this today as well, trying to sync the |
@arsatiki what do you expect the |
Tracking support in #6981 |
@zanieb I think the help texts for one or both options should mention that they are still trying to resolve all extras, even if they are not installed. At least I do not find it intuitive that an extra would affect the resolution, unless I specifically opt into the extra. (But I get why you have chosen the opposite strategy.) Since it does the (in my view) unintuitive thing, the relevant option should notify me about it. |
Thanks I'll update that. |
See #7013 |
This PR adds support for conflicting extras. For example, consider some optional dependencies like this: ```toml [project.optional-dependencies] project1 = ["numpy==1.26.3"] project2 = ["numpy==1.26.4"] ``` These dependency specifications are not compatible with one another. And if you ask uv to lock these, you'll get an unresolvable error. With this PR, you can now add this to your `pyproject.toml` to get around this: ```toml [tool.uv] conflicting-groups = [ [ { package = "project", extra = "project1" }, { package = "project", extra = "project2" }, ], ] ``` This will make the universal resolver create additional forks internally that keep the dependencies from the `project1` and `project2` extras separate. And we make all of this work by reporting an error at **install** time if one tries to install with two or more extras that have been declared as conflicting. (If we didn't do this, it would be possible to try and install two different versions of the same package into the same environment.) This PR does *not* add support for conflicting **groups**, but it is intended to add support in a follow-up PR. Closes #6981 Fixes #8024 Ref #6729, Ref #6830 This should also hopefully unblock dagster-io/dagster#23814, but in my testing, I did run into other problems (specifically, with `pywin`). But it does resolve the problem with incompatible dependencies in two different extras once you declare `test-airflow-1` and `test-airflow-2` as conflicting for `dagster-airflow`. NOTE: This PR doesn't make `conflicting-groups` public yet. And in a follow-up PR, I plan to switch the name to `conflicts` instead of `conflicting-groups`, since it will be able to accept conflicting extras _and_ conflicting groups.
I have a variation of this problem, but not so much with conflicting extras, but rather with missing extras:
I was hoping that I would be able to do
I also tried adding dependency-metadata for this package in the hope that it wouldn't try to find it, but that didn't help. I'm guessing that the solution proposed in #8976 doesn't really help in this situation? |
the initial options of
uv sync
would lead me to believe that extras should not be resolved by defaultyet when I try to run it, I get e.g:
It's weird, because if I remove
projectx
from thedoc
optional-dependencies, it works and none of the other dependencies indoc
are included in the.venv
I see this is because
uv
tries to add alloptional-dependencies
to theuv.lock
first, but what if I do not want them in there, because they have incompatibilitiesThe text was updated successfully, but these errors were encountered: