mirror of https://github.com/astral-sh/uv
Use more precise error messages for preparation failures
This commit is contained in:
parent
91585a90e7
commit
66211cb028
|
|
@ -11,7 +11,8 @@ use uv_cache::Cache;
|
||||||
use uv_configuration::BuildOptions;
|
use uv_configuration::BuildOptions;
|
||||||
use uv_distribution::{DistributionDatabase, LocalWheel};
|
use uv_distribution::{DistributionDatabase, LocalWheel};
|
||||||
use uv_distribution_types::{
|
use uv_distribution_types::{
|
||||||
BuildableSource, CachedDist, Dist, Hashed, Identifier, Name, RemoteSource,
|
BuildableSource, BuiltDist, CachedDist, Dist, Hashed, Identifier, Name, RemoteSource,
|
||||||
|
SourceDist,
|
||||||
};
|
};
|
||||||
use uv_platform_tags::Tags;
|
use uv_platform_tags::Tags;
|
||||||
use uv_types::{BuildContext, HashStrategy, InFlight};
|
use uv_types::{BuildContext, HashStrategy, InFlight};
|
||||||
|
|
@ -24,8 +25,12 @@ pub enum Error {
|
||||||
NoBinary(PackageName),
|
NoBinary(PackageName),
|
||||||
#[error("Failed to unzip wheel: {0}")]
|
#[error("Failed to unzip wheel: {0}")]
|
||||||
Unzip(Dist, #[source] Box<uv_extract::Error>),
|
Unzip(Dist, #[source] Box<uv_extract::Error>),
|
||||||
#[error("Failed to fetch wheel: {0}")]
|
#[error("Failed to download `{0}`")]
|
||||||
Fetch(Dist, #[source] Box<uv_distribution::Error>),
|
Fetch(BuiltDist, #[source] Box<uv_distribution::Error>),
|
||||||
|
#[error("Failed to download and build `{0}`")]
|
||||||
|
FetchAndBuild(SourceDist, #[source] Box<uv_distribution::Error>),
|
||||||
|
#[error("Failed to build `{0}`")]
|
||||||
|
Build(SourceDist, #[source] Box<uv_distribution::Error>),
|
||||||
/// Should not occur; only seen when another task panicked.
|
/// Should not occur; only seen when another task panicked.
|
||||||
#[error("The task executor is broken, did some other task panic?")]
|
#[error("The task executor is broken, did some other task panic?")]
|
||||||
Join(#[from] JoinError),
|
Join(#[from] JoinError),
|
||||||
|
|
@ -150,20 +155,36 @@ impl<'a, Context: BuildContext> Preparer<'a, Context> {
|
||||||
.database
|
.database
|
||||||
.get_or_build_wheel(&dist, self.tags, policy)
|
.get_or_build_wheel(&dist, self.tags, policy)
|
||||||
.boxed_local()
|
.boxed_local()
|
||||||
.map_err(|err| Error::Fetch(dist.clone(), Box::new(err)))
|
.map_err(|err| match &dist {
|
||||||
|
Dist::Built(dist) => Error::Fetch(dist.clone(), Box::new(err)),
|
||||||
|
Dist::Source(dist) => {
|
||||||
|
if dist.is_local() {
|
||||||
|
Error::Build(dist.clone(), Box::new(err))
|
||||||
|
} else {
|
||||||
|
Error::FetchAndBuild(dist.clone(), Box::new(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.and_then(|wheel: LocalWheel| {
|
.and_then(|wheel: LocalWheel| {
|
||||||
if wheel.satisfies(policy) {
|
if wheel.satisfies(policy) {
|
||||||
Ok(wheel)
|
Ok(wheel)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Fetch(
|
let err = uv_distribution::Error::hash_mismatch(
|
||||||
dist.clone(),
|
dist.to_string(),
|
||||||
Box::new(uv_distribution::Error::hash_mismatch(
|
policy.digests(),
|
||||||
dist.to_string(),
|
wheel.hashes(),
|
||||||
policy.digests(),
|
);
|
||||||
wheel.hashes(),
|
Err(match &dist {
|
||||||
)),
|
Dist::Built(dist) => Error::Fetch(dist.clone(), Box::new(err)),
|
||||||
))
|
Dist::Source(dist) => {
|
||||||
|
if dist.is_local() {
|
||||||
|
Error::Build(dist.clone(), Box::new(err))
|
||||||
|
} else {
|
||||||
|
Error::FetchAndBuild(dist.clone(), Box::new(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(CachedDist::from);
|
.map(CachedDist::from);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue