@@ -29,7 +29,7 @@ use uv_configuration::{BuildKind, BuildOutput, SourceStrategy};
2929use uv_distribution_filename:: { SourceDistExtension , WheelFilename } ;
3030use uv_distribution_types:: {
3131 BuildableSource , DirectorySourceUrl , FileLocation , GitSourceUrl , HashPolicy , Hashed ,
32- PathSourceUrl , RemoteSource , SourceDist , SourceUrl ,
32+ PathSourceUrl , SourceDist , SourceUrl ,
3333} ;
3434use uv_extract:: hash:: Hasher ;
3535use uv_fs:: { rename_with_retry, write_atomic, LockedFile } ;
@@ -58,6 +58,9 @@ pub(crate) const LOCAL_REVISION: &str = "revision.rev";
5858/// The name of the file that contains the cached distribution metadata, encoded via `MsgPack`.
5959pub ( crate ) const METADATA : & str = "metadata.msgpack" ;
6060
61+ /// The directory within each entry under which to store the unpacked source distribution.
62+ pub ( crate ) const SOURCE : & str = "src" ;
63+
6164impl < ' a , T : BuildContext > SourceDistributionBuilder < ' a , T > {
6265 /// Initialize a [`SourceDistributionBuilder`] from a [`BuildContext`].
6366 pub ( crate ) fn new ( build_context : & ' a T ) -> Self {
@@ -125,7 +128,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
125128
126129 self . url (
127130 source,
128- & dist. file . filename ,
129131 & url,
130132 & cache_shard,
131133 None ,
@@ -138,8 +140,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
138140 . await ?
139141 }
140142 BuildableSource :: Dist ( SourceDist :: DirectUrl ( dist) ) => {
141- let filename = dist. filename ( ) . expect ( "Distribution must have a filename" ) ;
142-
143143 // For direct URLs, cache directly under the hash of the URL itself.
144144 let cache_shard = self . build_context . cache ( ) . shard (
145145 CacheBucket :: SourceDistributions ,
@@ -148,7 +148,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
148148
149149 self . url (
150150 source,
151- & filename,
152151 & dist. url ,
153152 & cache_shard,
154153 dist. subdirectory . as_deref ( ) ,
@@ -186,11 +185,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
186185 . await ?
187186 }
188187 BuildableSource :: Url ( SourceUrl :: Direct ( resource) ) => {
189- let filename = resource
190- . url
191- . filename ( )
192- . expect ( "Distribution must have a filename" ) ;
193-
194188 // For direct URLs, cache directly under the hash of the URL itself.
195189 let cache_shard = self . build_context . cache ( ) . shard (
196190 CacheBucket :: SourceDistributions ,
@@ -199,7 +193,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
199193
200194 self . url (
201195 source,
202- & filename,
203196 resource. url ,
204197 & cache_shard,
205198 resource. subdirectory ,
@@ -281,22 +274,11 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
281274 . await ;
282275 }
283276
284- self . url_metadata (
285- source,
286- & dist. file . filename ,
287- & url,
288- & cache_shard,
289- None ,
290- dist. ext ,
291- hashes,
292- client,
293- )
294- . boxed_local ( )
295- . await ?
277+ self . url_metadata ( source, & url, & cache_shard, None , dist. ext , hashes, client)
278+ . boxed_local ( )
279+ . await ?
296280 }
297281 BuildableSource :: Dist ( SourceDist :: DirectUrl ( dist) ) => {
298- let filename = dist. filename ( ) . expect ( "Distribution must have a filename" ) ;
299-
300282 // For direct URLs, cache directly under the hash of the URL itself.
301283 let cache_shard = self . build_context . cache ( ) . shard (
302284 CacheBucket :: SourceDistributions ,
@@ -305,7 +287,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
305287
306288 self . url_metadata (
307289 source,
308- & filename,
309290 & dist. url ,
310291 & cache_shard,
311292 dist. subdirectory . as_deref ( ) ,
@@ -336,11 +317,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
336317 . await ?
337318 }
338319 BuildableSource :: Url ( SourceUrl :: Direct ( resource) ) => {
339- let filename = resource
340- . url
341- . filename ( )
342- . expect ( "Distribution must have a filename" ) ;
343-
344320 // For direct URLs, cache directly under the hash of the URL itself.
345321 let cache_shard = self . build_context . cache ( ) . shard (
346322 CacheBucket :: SourceDistributions ,
@@ -349,7 +325,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
349325
350326 self . url_metadata (
351327 source,
352- & filename,
353328 resource. url ,
354329 & cache_shard,
355330 resource. subdirectory ,
@@ -403,7 +378,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
403378 async fn url < ' data > (
404379 & self ,
405380 source : & BuildableSource < ' data > ,
406- filename : & ' data str ,
407381 url : & ' data Url ,
408382 cache_shard : & CacheShard ,
409383 subdirectory : Option < & ' data Path > ,
@@ -416,7 +390,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
416390
417391 // Fetch the revision for the source distribution.
418392 let revision = self
419- . url_revision ( source, filename , ext, url, cache_shard, hashes, client)
393+ . url_revision ( source, ext, url, cache_shard, hashes, client)
420394 . await ?;
421395
422396 // Before running the build, check that the hashes match.
@@ -431,7 +405,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
431405 // Scope all operations to the revision. Within the revision, there's no need to check for
432406 // freshness, since entries have to be fresher than the revision itself.
433407 let cache_shard = cache_shard. shard ( revision. id ( ) ) ;
434- let source_dist_entry = cache_shard. entry ( filename ) ;
408+ let source_dist_entry = cache_shard. entry ( SOURCE ) ;
435409
436410 // If there are build settings, we need to scope to a cache shard.
437411 let config_settings = self . build_context . config_settings ( ) ;
@@ -452,7 +426,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
452426 } else {
453427 self . heal_url_revision (
454428 source,
455- filename,
456429 ext,
457430 url,
458431 & source_dist_entry,
@@ -507,7 +480,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
507480 async fn url_metadata < ' data > (
508481 & self ,
509482 source : & BuildableSource < ' data > ,
510- filename : & ' data str ,
511483 url : & ' data Url ,
512484 cache_shard : & CacheShard ,
513485 subdirectory : Option < & ' data Path > ,
@@ -519,7 +491,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
519491
520492 // Fetch the revision for the source distribution.
521493 let revision = self
522- . url_revision ( source, filename , ext, url, cache_shard, hashes, client)
494+ . url_revision ( source, ext, url, cache_shard, hashes, client)
523495 . await ?;
524496
525497 // Before running the build, check that the hashes match.
@@ -534,7 +506,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
534506 // Scope all operations to the revision. Within the revision, there's no need to check for
535507 // freshness, since entries have to be fresher than the revision itself.
536508 let cache_shard = cache_shard. shard ( revision. id ( ) ) ;
537- let source_dist_entry = cache_shard. entry ( filename ) ;
509+ let source_dist_entry = cache_shard. entry ( SOURCE ) ;
538510
539511 // If the metadata is static, return it.
540512 if let Some ( metadata) =
@@ -562,7 +534,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
562534 } else {
563535 self . heal_url_revision (
564536 source,
565- filename,
566537 ext,
567538 url,
568539 & source_dist_entry,
@@ -644,7 +615,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
644615 async fn url_revision (
645616 & self ,
646617 source : & BuildableSource < ' _ > ,
647- filename : & str ,
648618 ext : SourceDistExtension ,
649619 url : & Url ,
650620 cache_shard : & CacheShard ,
@@ -670,9 +640,9 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
670640
671641 // Download the source distribution.
672642 debug ! ( "Downloading source distribution: {source}" ) ;
673- let entry = cache_shard. shard ( revision. id ( ) ) . entry ( filename ) ;
643+ let entry = cache_shard. shard ( revision. id ( ) ) . entry ( SOURCE ) ;
674644 let hashes = self
675- . download_archive ( response, source, filename , ext, entry. path ( ) , hashes)
645+ . download_archive ( response, source, ext, entry. path ( ) , hashes)
676646 . await ?;
677647
678648 Ok ( revision. with_hashes ( hashes) )
@@ -743,7 +713,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
743713 // Scope all operations to the revision. Within the revision, there's no need to check for
744714 // freshness, since entries have to be fresher than the revision itself.
745715 let cache_shard = cache_shard. shard ( revision. id ( ) ) ;
746- let source_entry = cache_shard. entry ( "source" ) ;
716+ let source_entry = cache_shard. entry ( SOURCE ) ;
747717
748718 // If there are build settings, we need to scope to a cache shard.
749719 let config_settings = self . build_context . config_settings ( ) ;
@@ -832,7 +802,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
832802 // Scope all operations to the revision. Within the revision, there's no need to check for
833803 // freshness, since entries have to be fresher than the revision itself.
834804 let cache_shard = cache_shard. shard ( revision. id ( ) ) ;
835- let source_entry = cache_shard. entry ( "source" ) ;
805+ let source_entry = cache_shard. entry ( SOURCE ) ;
836806
837807 // If the metadata is static, return it.
838808 if let Some ( metadata) =
@@ -957,7 +927,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
957927
958928 // Unzip the archive to a temporary directory.
959929 debug ! ( "Unpacking source distribution: {source}" ) ;
960- let entry = cache_shard. shard ( revision. id ( ) ) . entry ( "source" ) ;
930+ let entry = cache_shard. shard ( revision. id ( ) ) . entry ( SOURCE ) ;
961931 let hashes = self
962932 . persist_archive ( & resource. path , resource. ext , entry. path ( ) , hashes)
963933 . await ?;
@@ -1568,7 +1538,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
15681538 async fn heal_url_revision (
15691539 & self ,
15701540 source : & BuildableSource < ' _ > ,
1571- filename : & str ,
15721541 ext : SourceDistExtension ,
15731542 url : & Url ,
15741543 entry : & CacheEntry ,
@@ -1581,7 +1550,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
15811550 let download = |response| {
15821551 async {
15831552 let hashes = self
1584- . download_archive ( response, source, filename , ext, entry. path ( ) , hashes)
1553+ . download_archive ( response, source, ext, entry. path ( ) , hashes)
15851554 . await ?;
15861555 if hashes != revision. hashes ( ) {
15871556 return Err ( Error :: CacheHeal ( source. to_string ( ) ) ) ;
@@ -1610,7 +1579,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
16101579 & self ,
16111580 response : Response ,
16121581 source : & BuildableSource < ' _ > ,
1613- filename : & str ,
16141582 ext : SourceDistExtension ,
16151583 target : & Path ,
16161584 hashes : HashPolicy < ' _ > ,
@@ -1632,7 +1600,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
16321600 let mut hasher = uv_extract:: hash:: HashReader :: new ( reader. compat ( ) , & mut hashers) ;
16331601
16341602 // Download and unzip the source distribution into a temporary directory.
1635- let span = info_span ! ( "download_source_dist" , filename = filename , source_dist = %source) ;
1603+ let span = info_span ! ( "download_source_dist" , source_dist = %source) ;
16361604 uv_extract:: stream:: archive ( & mut hasher, ext, temp_dir. path ( ) ) . await ?;
16371605 drop ( span) ;
16381606
0 commit comments