diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index 43fdabb7c..e846ab640 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -704,10 +704,7 @@ impl RegistryClient { pub async fn fetch_simple_index( &self, index_url: &IndexUrl, - download_concurrency: &Semaphore, ) -> Result { - let _permit = download_concurrency.acquire().await; - // Format the URL for PyPI. let mut url = index_url.url().clone(); url.path_segments_mut() @@ -1309,10 +1306,15 @@ pub struct VersionSourceDist { #[rkyv(derive(Debug))] pub struct SimpleIndexMetadata { /// The list of project names available in the index. - pub projects: Vec, + projects: Vec, } impl SimpleIndexMetadata { + /// Iterate over the projects in the index. + pub fn iter(&self) -> impl Iterator { + self.projects.iter() + } + /// Create a [`SimpleIndexMetadata`] from a [`PypiSimpleIndex`]. fn from_pypi_index(index: PypiSimpleIndex) -> Self { Self { diff --git a/crates/uv-dev/src/list_packages.rs b/crates/uv-dev/src/list_packages.rs index d5cfc14f7..0641bf617 100644 --- a/crates/uv-dev/src/list_packages.rs +++ b/crates/uv-dev/src/list_packages.rs @@ -1,7 +1,6 @@ use anstream::println; use anyhow::Result; use clap::Parser; -use tokio::sync::Semaphore; use uv_cache::{Cache, CacheArgs}; use uv_client::{BaseClientBuilder, RegistryClientBuilder}; @@ -28,10 +27,9 @@ pub(crate) async fn list_packages( .build(); let index_url = IndexUrl::parse(&args.url, None)?; - let concurrency = Semaphore::new(Semaphore::MAX_PERMITS); - let index = client.fetch_simple_index(&index_url, &concurrency).await?; + let index = client.fetch_simple_index(&index_url).await?; - for package_name in &index.projects { + for package_name in index.iter() { println!("{}", package_name); } diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs index 93b68226c..769919585 100644 --- a/crates/uv-distribution/src/source/mod.rs +++ b/crates/uv-distribution/src/source/mod.rs @@ -1536,8 +1536,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { return Err(Error::HashesNotSupportedGit(source.to_string())); } - // STOPSHIP(charlie): Here, we can fetch the pre-built wheel. - // Fetch the Git repository. let fetch = self .build_context diff --git a/hash_test.py b/hash_test.py deleted file mode 100644 index 9f8288aba..000000000 --- a/hash_test.py +++ /dev/null @@ -1,50 +0,0 @@ -from hashlib import blake2b -from os import fspath -from typing import Optional, Union - -Pathish = Union[str, bytes, "os.PathLike[str]", "os.PathLike[bytes]"] - -def git_cache_digest(repository: str, precise: str, subdirectory: Optional[Pathish] = None) -> str: - """ - Reproduces the Rust digest() exactly: - - - blake2b with 32-byte (256-bit) digest - - bytes fed in this order: - repository + "/" + precise [+ "?subdirectory=" + subdirectory] - - subdirectory is included only if it is representable as UTF-8 - (mirrors Rust Path::to_str() -> Option<&str>) - - hex output is lowercase - """ - h = blake2b(digest_size=32) - - # repository and precise are Rust &str equivalents: encode as UTF-8 - h.update(repository.encode("utf-8")) - h.update(b"/") - h.update(precise.encode("utf-8")) - - if subdirectory is not None: - # Normalize to either str or bytes using fspath (handles PathLike) - p = fspath(subdirectory) - - # Try to get a UTF-8 string like Path::to_str() - if isinstance(p, bytes): - try: - p_str = p.decode("utf-8") - except UnicodeDecodeError: - p_str = None - else: - # Already a str - p_str = p - - if p_str is not None: - h.update(b"?subdirectory=") - h.update(p_str.encode("utf-8")) - - return h.hexdigest() - -digest = git_cache_digest( - repository="https://github.com/agronholm/anyio", - precise="64b753b19c9a49e3ae395cde457cf82d51f7e999", - subdirectory=None -) -print(digest) # lowercase hex, identical to the Rust version