mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Fetch from data-dist-info-metadata
when available (#37)
As specified in https://peps.python.org/pep-0658/#specification.
This commit is contained in:
parent
ae28552b3a
commit
6c31631913
1 changed files with 20 additions and 6 deletions
|
@ -66,12 +66,17 @@ impl PypiClient {
|
|||
|
||||
/// Fetch the metadata from a wheel file.
|
||||
pub async fn file(&self, file: File) -> Result<Metadata21, PypiClientError> {
|
||||
// Send to the proxy.
|
||||
let url = self.proxy.join(
|
||||
file.url
|
||||
.strip_prefix("https://files.pythonhosted.org/")
|
||||
.unwrap(),
|
||||
)?;
|
||||
// Per PEP 658, if `data-dist-info-metadata` is available, we can request it directly;
|
||||
// otherwise, send to our dedicated caching proxy.
|
||||
let url = if file.data_dist_info_metadata.is_available() {
|
||||
Url::parse(&format!("{}.metadata", file.url))?
|
||||
} else {
|
||||
self.proxy.join(
|
||||
file.url
|
||||
.strip_prefix("https://files.pythonhosted.org/")
|
||||
.unwrap(),
|
||||
)?
|
||||
};
|
||||
|
||||
trace!("fetching file {} from {}", file.filename, url);
|
||||
|
||||
|
@ -155,6 +160,15 @@ pub enum Metadata {
|
|||
Hashes(Hashes),
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
pub fn is_available(&self) -> bool {
|
||||
match self {
|
||||
Self::Bool(is_available) => *is_available,
|
||||
Self::Hashes(_) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum Yanked {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue