mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Fetch wheel metadata by async range requests on the remote wheel (#301)
Use range requests and async zip to extract the METADATA file from a remote wheel. We currently only cache when the remote says the remote declares the resource as immutable, see https://github.com/06chaynes/http-cache/issues/57 and https://github.com/baszalmstra/async_http_range_reader/pull/1 . The cache is stored as json with the description omitted, this improve cache deserialization performance.
This commit is contained in:
parent
6f83a44fea
commit
b2439b24a1
15 changed files with 558 additions and 68 deletions
28
crates/puffin-client/tests/remote_metadata.rs
Normal file
28
crates/puffin-client/tests/remote_metadata.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Result;
|
||||
use tempfile::tempdir;
|
||||
use url::Url;
|
||||
|
||||
use distribution_filename::WheelFilename;
|
||||
use puffin_client::RegistryClientBuilder;
|
||||
|
||||
#[tokio::test]
|
||||
async fn remote_metadata_with_and_without_cache() -> Result<()> {
|
||||
let temp_cache = tempdir().unwrap();
|
||||
let client = RegistryClientBuilder::default()
|
||||
.cache(Some(temp_cache.path().to_path_buf()))
|
||||
.build();
|
||||
// The first run is without cache (the tempdir is empty), the second has the cache from the
|
||||
// first run
|
||||
for _ in 0..2 {
|
||||
let url = "https://files.pythonhosted.org/packages/00/e5/f12a80907d0884e6dff9c16d0c0114d81b8cd07dc3ae54c5e962cc83037e/tqdm-4.66.1-py3-none-any.whl";
|
||||
let filename = WheelFilename::from_str(url.rsplit_once('/').unwrap().1).unwrap();
|
||||
let metadata = client
|
||||
.wheel_metadata_no_index(&filename, &Url::parse(url).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(metadata.summary.unwrap(), "Fast, Extensible Progress Meter");
|
||||
}
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue