mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Refactor distribution types to return Result
(#470)
## Summary A variety of small refactors to the distribution types crate to (1) return `Result` if we find an invalid wheel, rather than treating it as a source distribution with a `.whl` suffix, and (2) DRY up some repeated code around URLs.
This commit is contained in:
parent
f0841cdb6e
commit
f1aa70d9d3
12 changed files with 119 additions and 97 deletions
|
@ -13,6 +13,7 @@ use distribution_filename::WheelFilename;
|
|||
use distribution_types::direct_url::{DirectArchiveUrl, DirectGitUrl};
|
||||
use distribution_types::{BuiltDist, Dist, Identifier, Metadata, RemoteSource, SourceDist};
|
||||
use platform_tags::Tags;
|
||||
use puffin_cache::metadata::WheelMetadataCache;
|
||||
use puffin_client::RegistryClient;
|
||||
use puffin_git::{GitSource, GitUrl};
|
||||
use puffin_traits::BuildContext;
|
||||
|
@ -77,6 +78,13 @@ impl<'a> Fetcher<'a> {
|
|||
.await?;
|
||||
Ok(metadata)
|
||||
}
|
||||
// Fetch the metadata directly from the wheel URL.
|
||||
Dist::Built(BuiltDist::DirectUrl(wheel)) => {
|
||||
let metadata = client
|
||||
.wheel_metadata_no_pep658(&wheel.filename, &wheel.url, WheelMetadataCache::Url)
|
||||
.await?;
|
||||
Ok(metadata)
|
||||
}
|
||||
// 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? {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue