diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs
index a128aec519412..7672848c795cf 100644
--- a/crates/uv-distribution/src/source/mod.rs
+++ b/crates/uv-distribution/src/source/mod.rs
@@ -535,6 +535,17 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
// Scope all operations to the revision. Within the revision, there's no need to check for
// freshness, since entries have to be fresher than the revision itself.
let cache_shard = cache_shard.shard(revision.id());
+ let source_dist_entry = cache_shard.entry(filename);
+
+ // If the metadata is static, return it.
+ if let Some(metadata) =
+ Self::read_static_metadata(source, source_dist_entry.path(), subdirectory).await?
+ {
+ return Ok(ArchiveMetadata {
+ metadata: Metadata::from_metadata23(metadata),
+ hashes: revision.into_hashes(),
+ });
+ }
// If the cache contains compatible metadata, return it.
let metadata_entry = cache_shard.entry(METADATA);
@@ -547,8 +558,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
}
// Otherwise, we either need to build the metadata or the wheel.
- let source_dist_entry = cache_shard.entry(filename);
-
// If the backend supports `prepare_metadata_for_build_wheel`, use it.
if let Some(metadata) = self
.build_metadata(source, source_dist_entry.path(), subdirectory)
@@ -764,6 +773,17 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
// Scope all operations to the revision. Within the revision, there's no need to check for
// freshness, since entries have to be fresher than the revision itself.
let cache_shard = cache_shard.shard(revision.id());
+ let source_entry = cache_shard.entry("source");
+
+ // If the metadata is static, return it.
+ if let Some(metadata) =
+ Self::read_static_metadata(source, source_entry.path(), None).await?
+ {
+ return Ok(ArchiveMetadata {
+ metadata: Metadata::from_metadata23(metadata),
+ hashes: revision.into_hashes(),
+ });
+ }
// If the cache contains compatible metadata, return it.
let metadata_entry = cache_shard.entry(METADATA);
@@ -775,8 +795,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
});
}
- let source_entry = cache_shard.entry("source");
-
// If the backend supports `prepare_metadata_for_build_wheel`, use it.
if let Some(metadata) = self
.build_metadata(source, source_entry.path(), None)
@@ -984,6 +1002,20 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
// freshness, since entries have to be fresher than the revision itself.
let cache_shard = cache_shard.shard(revision.id());
+ if let Some(metadata) =
+ Self::read_static_metadata(source, &resource.install_path, None).await?
+ {
+ return Ok(ArchiveMetadata::from(
+ Metadata::from_workspace(
+ metadata,
+ resource.install_path.as_ref(),
+ resource.lock_path.as_ref(),
+ self.build_context.sources(),
+ )
+ .await?,
+ ));
+ }
+
// If the cache contains compatible metadata, return it.
let metadata_entry = cache_shard.entry(METADATA);
if let Some(metadata) = read_cached_metadata(&metadata_entry).await? {
@@ -1210,8 +1242,24 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
let _lock = lock_shard(&cache_shard).await?;
+ let path = if let Some(subdirectory) = resource.subdirectory {
+ Cow::Owned(fetch.path().join(subdirectory))
+ } else {
+ Cow::Borrowed(fetch.path())
+ };
+
+ if let Some(metadata) =
+ Self::read_static_metadata(source, fetch.path(), resource.subdirectory).await?
+ {
+ return Ok(ArchiveMetadata::from(
+ Metadata::from_workspace(metadata, &path, &path, self.build_context.sources())
+ .await?,
+ ));
+ }
+
// If the cache contains compatible metadata, return it.
let metadata_entry = cache_shard.entry(METADATA);
+
if self
.build_context
.cache()
@@ -1248,12 +1296,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
.await
.map_err(Error::CacheWrite)?;
- let path = if let Some(subdirectory) = resource.subdirectory {
- Cow::Owned(fetch.path().join(subdirectory))
- } else {
- Cow::Borrowed(fetch.path())
- };
-
return Ok(ArchiveMetadata::from(
Metadata::from_workspace(metadata, &path, &path, self.build_context.sources())
.await?,
@@ -1471,6 +1513,47 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
) -> Result