add support for package level conflicts with groups#9130
add support for package level conflicts with groups#9130BurntSushi wants to merge 22 commits intomainfrom
Conversation
112eb32 to
5bc4ca5
Compare
5bc4ca5 to
15202ea
Compare
This makes a lot more sense as a name IMO. And I think also works better for the immediate future, where I plan to add a `Project` kind.
Basically, this new conflict kind means that the entire project conflicts with a dependency group or an extra. This just adds the variant. In the next commit, we'll actually make it work.
Supporting project level conflicts ends up being pretty tricky, mostly because depenedency groups are represented as dependencies of the project you're trying to declare a conflict for. So by filtering out the project in the fork for the conflicting group, you end up filtering out the group itself too. To work-around this, we add a `parent` field to `PubGrubDependency`, and use this to filter based on project conflicts. This lets us do "delayed" filtering by one level. The rest of the changes in this commit are for reporting errors when you try to activate the group without disabling the project.
15202ea to
7fba6b5
Compare
|
(I think the experience makes sense, not feeling confident about reviewing the implementation) |
|
I've done a very dubious update with |
c8c89e1 to
3d3a5d8
Compare
3d3a5d8 to
b5a631f
Compare
b5a631f to
63122fe
Compare
63122fe to
8025a23
Compare
8025a23 to
4c1f9df
Compare
4c1f9df to
5248497
Compare
5248497 to
528c2ac
Compare
528c2ac to
39c3ccf
Compare
|
OK, I've pushed up a commit that I think gets this PR into working shape. There was a fair bit missing from
I think all the bones for this are there, but it doesn't seem to be fully working. Here's a simple concrete example. The root [project]
name = "example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = ["sortedcontainers==2.3.0"]
[tool.uv.workspace]
members = ["subexample"]
[tool.uv]
conflicts = [
[
{ package = "example" },
{ package = "subexample" },
],
]
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"And now [project]
name = "subexample"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = ["sortedcontainers==2.4.0"]Without the conflicts declared here, this would normally fail to generate a lock file. But that part works and seems to generate a correct lock. But syncing fails (ignore the bad error messages for now): In order for these package level conflicts to work, there has to be way to sync only a specific package or set of packages. |
|
(I'm still tagged here from the previous review, let me know if you want me to do another round) |
|
Thank you for addressing the problems!
We do already sync a subset, e.g., I don't think |
This reverts commit 3c1057d.
| "#, | ||
| )?; | ||
|
|
||
| uv_snapshot!(context.filters(), context.lock(), @r###" |
There was a problem hiding this comment.
Just insta version churn / noise in this file.
|
I'm going to move this to another pull request since it's got a pretty different scope now and it's a pain to keep looking up Andrew's PRs instead of my own :) See #14906 |
Revives #9130 Previously, we allowed scoping conflicting extras or groups to specific packages, e.g. ,`{ package = "foo", extra = "bar" }` for a conflict in `foo[bar]`. Now, we allow dropping the `extra` or `group` bit and using `{ package = "foo" }` directly which declares a conflict with `foo`'s production dependencies. This means you can declare conflicts between workspace members, e.g.: ``` [tool.uv] conflicts = [[{ package = "foo" }, { package = "bar" }]] ``` would not allow `foo` and `bar` to be installed at the same time. Similarly, a conflict can be declared between a package and a group: ``` [tool.uv] conflicts = [[{ package = "foo" }, { group = "lint" }]] ``` which would mean, e.g., that `--only-group lint` would be required for the invocation. As with our existing support for conflicting extras, there are edge-cases here where the resolver will _not_ fail even if there are conflicts that render a particular install target unusable. There's test coverage for some of these. We'll still error at install-time when the conflicting groups are selected. Due to the likelihood of bugs in this feature, I've marked it as a preview feature. I would not recommend reading the commits as there's some slop from not wanting to rebase Andrew's branch. --------- Co-authored-by: Andrew Gallant <andrew@astral.sh>
This PR adds support for declaring a conflict between a group
and a project's "production" dependencies. For example:
Before this PR, syntax like
{ package = "example" }wasn't allowed.This PR enables that syntax, and also tweaks the forking logic a bit
to support this.
I don't have 100% confidence in this PR. In particular, I'm not sure
if my trick adding a parent package to
PubGrubDependencyis fullycorrect. But I think it works.