Allow specific --only-binary and --no-binary packages to override :all: (#4067)

Updates `--no-binary <package>` to take precedence over `--only-binary
:all:` and `--only-binary <package>` to take precedence over
`--no-binary :all:`.

I'm not entirely sure about this behavior, e.g. maybe I provided
`--only-binary :all:` later on the command line and really want it to
override those earlier arguments of `--no-binary <package>` for safety.
Right now we just fail to solve though since we can't satisfy the
overlapping requests.

Closes https://github.com/astral-sh/uv/issues/4063
This commit is contained in:
Zanie Blue 2024-06-12 16:47:45 -04:00 committed by GitHub
parent cf830288f3
commit 1ab4041baa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 291 additions and 27 deletions

View file

@ -218,6 +218,7 @@ impl<'a> BuildContext for BuildDispatch<'a> {
site_packages,
&Reinstall::default(),
&NoBinary::default(),
&NoBuild::default(),
&HashStrategy::default(),
self.index_locations,
self.cache(),
@ -316,7 +317,17 @@ impl<'a> BuildContext for BuildDispatch<'a> {
) -> Result<SourceBuild> {
match self.no_build {
NoBuild::All => debug_assert!(
matches!(build_kind, BuildKind::Editable),
match self.no_binary {
// Allow `all` to be overridden by specific binary exclusions
NoBinary::Packages(packages) => {
if let Some(dist) = dist {
packages.contains(dist.name())
} else {
false
}
}
_ => false,
} || matches!(build_kind, BuildKind::Editable),
"Only editable builds are exempt from 'no build' checks"
),
NoBuild::None => {}