mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Error before download with no_build (#487)
This is fixes a performance regression where when `--no-build` was set, the fetcher would still download the source dist only to error afterwards.
This commit is contained in:
parent
e1dafe7203
commit
a030a466e6
1 changed files with 16 additions and 10 deletions
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{bail, Result};
|
||||
use bytesize::ByteSize;
|
||||
use fs_err::tokio as fs;
|
||||
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
||||
|
@ -87,17 +87,23 @@ impl<'a> Fetcher<'a> {
|
|||
}
|
||||
// Fetch the distribution, then read the metadata (for built distributions), or build
|
||||
// the distribution and _then_ read the metadata (for source distributions).
|
||||
dist => match self.fetch_dist(dist, client).await? {
|
||||
Download::Wheel(wheel) => {
|
||||
let metadata = wheel.read_dist_info()?;
|
||||
Ok(metadata)
|
||||
dist => {
|
||||
// Optimization: Skip source dist download when we must not build them anyway
|
||||
if build_context.no_build() && matches!(dist, Dist::Source(_)) {
|
||||
bail!("Building source distributions is disabled");
|
||||
}
|
||||
Download::SourceDist(sdist) => {
|
||||
let wheel = self.build_sdist(sdist, build_context).await?;
|
||||
let metadata = wheel.read_dist_info()?;
|
||||
Ok(metadata)
|
||||
match self.fetch_dist(dist, client).await? {
|
||||
Download::Wheel(wheel) => {
|
||||
let metadata = wheel.read_dist_info()?;
|
||||
Ok(metadata)
|
||||
}
|
||||
Download::SourceDist(sdist) => {
|
||||
let wheel = self.build_sdist(sdist, build_context).await?;
|
||||
let metadata = wheel.read_dist_info()?;
|
||||
Ok(metadata)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue