@@ -29,7 +29,7 @@ use uv_configuration::{BuildKind, BuildOutput, SourceStrategy};
29
29
use uv_distribution_filename:: { SourceDistExtension , WheelFilename } ;
30
30
use uv_distribution_types:: {
31
31
BuildableSource , DirectorySourceUrl , FileLocation , GitSourceUrl , HashPolicy , Hashed ,
32
- PathSourceUrl , RemoteSource , SourceDist , SourceUrl ,
32
+ PathSourceUrl , SourceDist , SourceUrl ,
33
33
} ;
34
34
use uv_extract:: hash:: Hasher ;
35
35
use uv_fs:: { rename_with_retry, write_atomic, LockedFile } ;
@@ -58,6 +58,9 @@ pub(crate) const LOCAL_REVISION: &str = "revision.rev";
58
58
/// The name of the file that contains the cached distribution metadata, encoded via `MsgPack`.
59
59
pub ( crate ) const METADATA : & str = "metadata.msgpack" ;
60
60
61
+ /// The directory within each entry under which to store the unpacked source distribution.
62
+ pub ( crate ) const SOURCE : & str = "src" ;
63
+
61
64
impl < ' a , T : BuildContext > SourceDistributionBuilder < ' a , T > {
62
65
/// Initialize a [`SourceDistributionBuilder`] from a [`BuildContext`].
63
66
pub ( crate ) fn new ( build_context : & ' a T ) -> Self {
@@ -125,7 +128,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
125
128
126
129
self . url (
127
130
source,
128
- & dist. file . filename ,
129
131
& url,
130
132
& cache_shard,
131
133
None ,
@@ -138,8 +140,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
138
140
. await ?
139
141
}
140
142
BuildableSource :: Dist ( SourceDist :: DirectUrl ( dist) ) => {
141
- let filename = dist. filename ( ) . expect ( "Distribution must have a filename" ) ;
142
-
143
143
// For direct URLs, cache directly under the hash of the URL itself.
144
144
let cache_shard = self . build_context . cache ( ) . shard (
145
145
CacheBucket :: SourceDistributions ,
@@ -148,7 +148,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
148
148
149
149
self . url (
150
150
source,
151
- & filename,
152
151
& dist. url ,
153
152
& cache_shard,
154
153
dist. subdirectory . as_deref ( ) ,
@@ -186,11 +185,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
186
185
. await ?
187
186
}
188
187
BuildableSource :: Url ( SourceUrl :: Direct ( resource) ) => {
189
- let filename = resource
190
- . url
191
- . filename ( )
192
- . expect ( "Distribution must have a filename" ) ;
193
-
194
188
// For direct URLs, cache directly under the hash of the URL itself.
195
189
let cache_shard = self . build_context . cache ( ) . shard (
196
190
CacheBucket :: SourceDistributions ,
@@ -199,7 +193,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
199
193
200
194
self . url (
201
195
source,
202
- & filename,
203
196
resource. url ,
204
197
& cache_shard,
205
198
resource. subdirectory ,
@@ -281,22 +274,11 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
281
274
. await ;
282
275
}
283
276
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 ?
296
280
}
297
281
BuildableSource :: Dist ( SourceDist :: DirectUrl ( dist) ) => {
298
- let filename = dist. filename ( ) . expect ( "Distribution must have a filename" ) ;
299
-
300
282
// For direct URLs, cache directly under the hash of the URL itself.
301
283
let cache_shard = self . build_context . cache ( ) . shard (
302
284
CacheBucket :: SourceDistributions ,
@@ -305,7 +287,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
305
287
306
288
self . url_metadata (
307
289
source,
308
- & filename,
309
290
& dist. url ,
310
291
& cache_shard,
311
292
dist. subdirectory . as_deref ( ) ,
@@ -336,11 +317,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
336
317
. await ?
337
318
}
338
319
BuildableSource :: Url ( SourceUrl :: Direct ( resource) ) => {
339
- let filename = resource
340
- . url
341
- . filename ( )
342
- . expect ( "Distribution must have a filename" ) ;
343
-
344
320
// For direct URLs, cache directly under the hash of the URL itself.
345
321
let cache_shard = self . build_context . cache ( ) . shard (
346
322
CacheBucket :: SourceDistributions ,
@@ -349,7 +325,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
349
325
350
326
self . url_metadata (
351
327
source,
352
- & filename,
353
328
resource. url ,
354
329
& cache_shard,
355
330
resource. subdirectory ,
@@ -403,7 +378,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
403
378
async fn url < ' data > (
404
379
& self ,
405
380
source : & BuildableSource < ' data > ,
406
- filename : & ' data str ,
407
381
url : & ' data Url ,
408
382
cache_shard : & CacheShard ,
409
383
subdirectory : Option < & ' data Path > ,
@@ -416,7 +390,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
416
390
417
391
// Fetch the revision for the source distribution.
418
392
let revision = self
419
- . url_revision ( source, filename , ext, url, cache_shard, hashes, client)
393
+ . url_revision ( source, ext, url, cache_shard, hashes, client)
420
394
. await ?;
421
395
422
396
// Before running the build, check that the hashes match.
@@ -431,7 +405,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
431
405
// Scope all operations to the revision. Within the revision, there's no need to check for
432
406
// freshness, since entries have to be fresher than the revision itself.
433
407
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 ) ;
435
409
436
410
// If there are build settings, we need to scope to a cache shard.
437
411
let config_settings = self . build_context . config_settings ( ) ;
@@ -452,7 +426,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
452
426
} else {
453
427
self . heal_url_revision (
454
428
source,
455
- filename,
456
429
ext,
457
430
url,
458
431
& source_dist_entry,
@@ -507,7 +480,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
507
480
async fn url_metadata < ' data > (
508
481
& self ,
509
482
source : & BuildableSource < ' data > ,
510
- filename : & ' data str ,
511
483
url : & ' data Url ,
512
484
cache_shard : & CacheShard ,
513
485
subdirectory : Option < & ' data Path > ,
@@ -519,7 +491,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
519
491
520
492
// Fetch the revision for the source distribution.
521
493
let revision = self
522
- . url_revision ( source, filename , ext, url, cache_shard, hashes, client)
494
+ . url_revision ( source, ext, url, cache_shard, hashes, client)
523
495
. await ?;
524
496
525
497
// Before running the build, check that the hashes match.
@@ -534,7 +506,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
534
506
// Scope all operations to the revision. Within the revision, there's no need to check for
535
507
// freshness, since entries have to be fresher than the revision itself.
536
508
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 ) ;
538
510
539
511
// If the metadata is static, return it.
540
512
if let Some ( metadata) =
@@ -562,7 +534,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
562
534
} else {
563
535
self . heal_url_revision (
564
536
source,
565
- filename,
566
537
ext,
567
538
url,
568
539
& source_dist_entry,
@@ -644,7 +615,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
644
615
async fn url_revision (
645
616
& self ,
646
617
source : & BuildableSource < ' _ > ,
647
- filename : & str ,
648
618
ext : SourceDistExtension ,
649
619
url : & Url ,
650
620
cache_shard : & CacheShard ,
@@ -670,9 +640,9 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
670
640
671
641
// Download the source distribution.
672
642
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 ) ;
674
644
let hashes = self
675
- . download_archive ( response, source, filename , ext, entry. path ( ) , hashes)
645
+ . download_archive ( response, source, ext, entry. path ( ) , hashes)
676
646
. await ?;
677
647
678
648
Ok ( revision. with_hashes ( hashes) )
@@ -743,7 +713,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
743
713
// Scope all operations to the revision. Within the revision, there's no need to check for
744
714
// freshness, since entries have to be fresher than the revision itself.
745
715
let cache_shard = cache_shard. shard ( revision. id ( ) ) ;
746
- let source_entry = cache_shard. entry ( "source" ) ;
716
+ let source_entry = cache_shard. entry ( SOURCE ) ;
747
717
748
718
// If there are build settings, we need to scope to a cache shard.
749
719
let config_settings = self . build_context . config_settings ( ) ;
@@ -832,7 +802,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
832
802
// Scope all operations to the revision. Within the revision, there's no need to check for
833
803
// freshness, since entries have to be fresher than the revision itself.
834
804
let cache_shard = cache_shard. shard ( revision. id ( ) ) ;
835
- let source_entry = cache_shard. entry ( "source" ) ;
805
+ let source_entry = cache_shard. entry ( SOURCE ) ;
836
806
837
807
// If the metadata is static, return it.
838
808
if let Some ( metadata) =
@@ -957,7 +927,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
957
927
958
928
// Unzip the archive to a temporary directory.
959
929
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 ) ;
961
931
let hashes = self
962
932
. persist_archive ( & resource. path , resource. ext , entry. path ( ) , hashes)
963
933
. await ?;
@@ -1568,7 +1538,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
1568
1538
async fn heal_url_revision (
1569
1539
& self ,
1570
1540
source : & BuildableSource < ' _ > ,
1571
- filename : & str ,
1572
1541
ext : SourceDistExtension ,
1573
1542
url : & Url ,
1574
1543
entry : & CacheEntry ,
@@ -1581,7 +1550,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
1581
1550
let download = |response| {
1582
1551
async {
1583
1552
let hashes = self
1584
- . download_archive ( response, source, filename , ext, entry. path ( ) , hashes)
1553
+ . download_archive ( response, source, ext, entry. path ( ) , hashes)
1585
1554
. await ?;
1586
1555
if hashes != revision. hashes ( ) {
1587
1556
return Err ( Error :: CacheHeal ( source. to_string ( ) ) ) ;
@@ -1610,7 +1579,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
1610
1579
& self ,
1611
1580
response : Response ,
1612
1581
source : & BuildableSource < ' _ > ,
1613
- filename : & str ,
1614
1582
ext : SourceDistExtension ,
1615
1583
target : & Path ,
1616
1584
hashes : HashPolicy < ' _ > ,
@@ -1632,7 +1600,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
1632
1600
let mut hasher = uv_extract:: hash:: HashReader :: new ( reader. compat ( ) , & mut hashers) ;
1633
1601
1634
1602
// 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) ;
1636
1604
uv_extract:: stream:: archive ( & mut hasher, ext, temp_dir. path ( ) ) . await ?;
1637
1605
drop ( span) ;
1638
1606
0 commit comments