uv-resolver: error during installation for conflicting extras

This collects ALL activated extras while traversing the lock file to
produce a `Resolution` for installation. If any two extras are activated
that are conflicting, then an error is produced.

We add a couple of tests to demonstrate the behavior. One case is
desirable (where we conditionally depend on `package[extra]`) and the
other case is undesirable (where we create an uninstallable lock file).

Fixes #9942, Fixes #10590
This commit is contained in:
Andrew Gallant 2025-01-22 14:25:21 -05:00 committed by Andrew Gallant
parent 1676e63603
commit a8d23da59c
3 changed files with 256 additions and 0 deletions

View file

@ -4897,6 +4897,16 @@ enum LockErrorKind {
#[source]
err: uv_distribution::Error,
},
#[error(
"Found conflicting extras `{package1}[{extra1}]` \
and `{package2}[{extra2}]` enabled simultaneously"
)]
ConflictingExtra {
package1: PackageName,
extra1: ExtraName,
package2: PackageName,
extra2: ExtraName,
},
}
/// An error that occurs when a source string could not be parsed.