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

@ -28,7 +28,7 @@ use uv_cache::{
use uv_client::{
CacheControl, CachedClientError, Connectivity, DataWithCachePolicy, RegistryClient,
};
use uv_configuration::{BuildKind, NoBuild, PreviewMode};
use uv_configuration::{BuildKind, NoBinary, NoBuild, PreviewMode};
use uv_extract::hash::Hasher;
use uv_fs::{write_atomic, LockedFile};
use uv_types::{BuildContext, SourceBuildTrait};
@ -1391,7 +1391,13 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
// Guard against build of source distributions when disabled.
let no_build = match self.build_context.no_build() {
NoBuild::All => true,
NoBuild::All => match self.build_context.no_binary() {
// Allow `all` to be overridden by specific binary exclusions
NoBinary::Packages(packages) => {
!source.name().is_some_and(|name| packages.contains(name))
}
_ => true,
},
NoBuild::None => false,
NoBuild::Packages(packages) => {
source.name().is_some_and(|name| packages.contains(name))