mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Add BuildOptions
for centralized combination of NoBuild
and NoBinary
(#4284)
As requested in review of https://github.com/astral-sh/uv/pull/4067
This commit is contained in:
parent
1ab4041baa
commit
5a007b6b9f
20 changed files with 186 additions and 267 deletions
|
@ -25,7 +25,7 @@ use uv_cache::{ArchiveId, ArchiveTimestamp, CacheBucket, CacheEntry, Timestamp,
|
|||
use uv_client::{
|
||||
CacheControl, CachedClientError, Connectivity, DataWithCachePolicy, RegistryClient,
|
||||
};
|
||||
use uv_configuration::{NoBinary, NoBuild, PreviewMode};
|
||||
use uv_configuration::PreviewMode;
|
||||
use uv_extract::hash::Hasher;
|
||||
use uv_fs::write_atomic;
|
||||
use uv_types::BuildContext;
|
||||
|
@ -145,17 +145,11 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
|
|||
dist: &BuiltDist,
|
||||
hashes: HashPolicy<'_>,
|
||||
) -> Result<LocalWheel, Error> {
|
||||
let no_binary = match self.build_context.no_binary() {
|
||||
NoBinary::None => false,
|
||||
NoBinary::All => match self.build_context.no_build() {
|
||||
// Allow `all` to be overridden by specific build exclusions
|
||||
NoBuild::Packages(packages) => !packages.contains(dist.name()),
|
||||
_ => true,
|
||||
},
|
||||
NoBinary::Packages(packages) => packages.contains(dist.name()),
|
||||
};
|
||||
|
||||
if no_binary {
|
||||
if self
|
||||
.build_context
|
||||
.build_options()
|
||||
.no_binary_package(dist.name())
|
||||
{
|
||||
return Err(Error::NoBinary);
|
||||
}
|
||||
|
||||
|
@ -418,22 +412,8 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
|
|||
source: &BuildableSource<'_>,
|
||||
hashes: HashPolicy<'_>,
|
||||
) -> Result<ArchiveMetadata, Error> {
|
||||
let no_build = match self.build_context.no_build() {
|
||||
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))
|
||||
}
|
||||
};
|
||||
|
||||
// Optimization: Skip source dist download when we must not build them anyway.
|
||||
if no_build {
|
||||
if self.build_context.build_options().no_build(source.name()) {
|
||||
if source.is_editable() {
|
||||
debug!("Allowing build for editable source distribution: {source}");
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue