Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 36f5ae7

Browse files
committedMar 18, 2025·
Exclude distributions from lock
1 parent 26cad18 commit 36f5ae7

File tree

3 files changed

+773
-5
lines changed

3 files changed

+773
-5
lines changed
 

‎crates/uv-distribution-types/src/prioritized_distribution.rs

+28-3
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ impl PrioritizedDist {
371371
self.0.markers.or(implied_markers(&dist.filename));
372372
}
373373
}
374+
// Track the hashes.
375+
if !compatibility.is_excluded() {
376+
self.0.hashes.extend(hashes);
377+
}
374378
// Track the highest-priority wheel.
375379
if let Some((.., existing_compatibility)) = self.best_wheel() {
376380
if compatibility.is_more_compatible(existing_compatibility) {
@@ -379,7 +383,6 @@ impl PrioritizedDist {
379383
} else {
380384
self.0.best_wheel_index = Some(self.0.wheels.len());
381385
}
382-
self.0.hashes.extend(hashes);
383386
self.0.wheels.push((dist, compatibility));
384387
}
385388

@@ -394,6 +397,10 @@ impl PrioritizedDist {
394397
if compatibility.is_compatible() {
395398
self.0.markers = MarkerTree::TRUE;
396399
}
400+
// Track the hashes.
401+
if !compatibility.is_excluded() {
402+
self.0.hashes.extend(hashes);
403+
}
397404
// Track the highest-priority source.
398405
if let Some((.., existing_compatibility)) = &self.0.source {
399406
if compatibility.is_more_compatible(existing_compatibility) {
@@ -402,7 +409,6 @@ impl PrioritizedDist {
402409
} else {
403410
self.0.source = Some((dist, compatibility));
404411
}
405-
self.0.hashes.extend(hashes);
406412
}
407413

408414
/// Return the highest-priority distribution for the package version, if any.
@@ -501,6 +507,7 @@ impl PrioritizedDist {
501507
.0
502508
.wheels
503509
.iter()
510+
.filter(|(_, compatibility)| !compatibility.is_excluded())
504511
.map(|(wheel, _)| wheel.clone())
505512
.collect();
506513
let sdist = self.0.source.as_ref().map(|(sdist, _)| sdist.clone());
@@ -514,7 +521,12 @@ impl PrioritizedDist {
514521
/// If this prioritized dist has an sdist, then this creates a source
515522
/// distribution.
516523
pub fn source_dist(&self) -> Option<RegistrySourceDist> {
517-
let mut sdist = self.0.source.as_ref().map(|(sdist, _)| sdist.clone())?;
524+
let mut sdist = self
525+
.0
526+
.source
527+
.as_ref()
528+
.filter(|(_, compatibility)| !compatibility.is_excluded())
529+
.map(|(sdist, _)| sdist.clone())?;
518530
assert!(
519531
sdist.wheels.is_empty(),
520532
"source distribution should not have any wheels yet"
@@ -623,6 +635,11 @@ impl WheelCompatibility {
623635
matches!(self, Self::Compatible(_, _, _))
624636
}
625637

638+
/// Return `true` if the distribution is excluded.
639+
pub fn is_excluded(&self) -> bool {
640+
matches!(self, Self::Incompatible(IncompatibleWheel::ExcludeNewer(_)))
641+
}
642+
626643
/// Return `true` if the current compatibility is more compatible than another.
627644
///
628645
/// Compatible wheels are always higher more compatible than incompatible wheels.
@@ -650,6 +667,14 @@ impl SourceDistCompatibility {
650667
matches!(self, Self::Compatible(_))
651668
}
652669

670+
/// Return `true` if the distribution is excluded.
671+
pub fn is_excluded(&self) -> bool {
672+
matches!(
673+
self,
674+
Self::Incompatible(IncompatibleSource::ExcludeNewer(_))
675+
)
676+
}
677+
653678
/// Return the higher priority compatibility.
654679
///
655680
/// Compatible source distributions are always higher priority than incompatible source distributions.

0 commit comments

Comments
 (0)
Please sign in to comment.