Skip to content

Commit cf4dba4

Browse files
committed
uv: expose conflicts in tool.uv in pyproject.toml
1 parent e2467de commit cf4dba4

File tree

3 files changed

+138
-7
lines changed

3 files changed

+138
-7
lines changed

crates/uv-workspace/src/pyproject.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ pub struct ToolUv {
460460
)]
461461
pub environments: Option<SupportedEnvironments>,
462462

463-
/// Conflicting extras may be declared here.
463+
/// Conflicting extras or groups may be declared here.
464464
///
465465
/// It's useful to declare conflicting extras when the extras have mutually
466466
/// incompatible dependencies. For example, extra `foo` might depend on
@@ -481,12 +481,8 @@ pub struct ToolUv {
481481
/// fail.
482482
#[cfg_attr(
483483
feature = "schemars",
484-
// Skipped for now while we iterate on this feature.
485-
schemars(skip, description = "A list sets of conflicting groups or extras.")
484+
schemars(description = "A list sets of conflicting groups or extras.")
486485
)]
487-
/*
488-
This is commented out temporarily while we finalize its
489-
functionality and naming. This avoids it showing up in docs.
490486
#[option(
491487
default = r#"[]"#,
492488
value_type = "list[list[dict]]",
@@ -500,9 +496,16 @@ pub struct ToolUv {
500496
{ extra = "test2" },
501497
]
502498
]
499+
500+
# Or, to declare conflicting groups:
501+
conflicts = [
502+
[
503+
{ group = "test1" },
504+
{ group = "test2" },
505+
]
506+
]
503507
"#
504508
)]
505-
*/
506509
pub conflicts: Option<SchemaConflicts>,
507510
}
508511

docs/reference/settings.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,55 @@
11
## Project metadata
2+
### [`conflicts`](#conflicts) {: #conflicts }
3+
4+
Conflicting extras or groups may be declared here.
5+
6+
It's useful to declare conflicting extras when the extras have mutually
7+
incompatible dependencies. For example, extra `foo` might depend on
8+
`numpy==2.0.0` while extra `bar` might depend on `numpy==2.1.0`. These
9+
extras cannot be activated at the same time. This usually isn't a
10+
problem for pip-style workflows, but when using uv project support
11+
with universal resolution, it will try to produce a resolution that
12+
satisfies both extras simultaneously.
13+
14+
When this happens, resolution will fail, because one cannot install
15+
both `numpy 2.0.0` and `numpy 2.1.0` into the same environment.
16+
17+
To work around this, you may specify `foo` and `bar` as conflicting
18+
extras. When doing universal resolution in project mode, these extras
19+
will get their own "forks" distinct from one another in order to permit
20+
conflicting dependencies. In exchange, if one tries to install from the
21+
lock file with both conflicting extras activated, installation will
22+
fail.
23+
24+
**Default value**: `[]`
25+
26+
**Type**: `list[list[dict]]`
27+
28+
**Example usage**:
29+
30+
```toml title="pyproject.toml"
31+
[tool.uv]
32+
# Require that `package[test1]` and `package[test2]`
33+
# requirements are resolved in different forks so that they
34+
# cannot conflict with one another.
35+
conflicts = [
36+
[
37+
{ extra = "test1" },
38+
{ extra = "test2" },
39+
]
40+
]
41+
42+
# Or, to declare conflicting groups:
43+
conflicts = [
44+
[
45+
{ group = "test1" },
46+
{ group = "test2" },
47+
]
48+
]
49+
```
50+
51+
---
52+
253
### [`constraint-dependencies`](#constraint-dependencies) {: #constraint-dependencies }
354

455
Constraints to apply when resolving the project's dependencies.

uv.schema.json

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)