Skip to content

Commit 0a8ca2d

Browse files
committed
Only apply to locals, if a version is available
1 parent 309e408 commit 0a8ca2d

File tree

6 files changed

+495
-368
lines changed

6 files changed

+495
-368
lines changed

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

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ impl IncompatibleDist {
119119
None => format!("has {self}"),
120120
},
121121
IncompatibleWheel::RequiresPython(..) => format!("requires {self}"),
122-
IncompatibleWheel::MissingPlatform(_) => {
123-
format!("has {self}")
124-
}
125122
},
126123
Self::Source(incompatibility) => match incompatibility {
127124
IncompatibleSource::NoBuild => format!("has {self}"),
@@ -149,9 +146,6 @@ impl IncompatibleDist {
149146
None => format!("have {self}"),
150147
},
151148
IncompatibleWheel::RequiresPython(..) => format!("require {self}"),
152-
IncompatibleWheel::MissingPlatform(_) => {
153-
format!("have {self}")
154-
}
155149
},
156150
Self::Source(incompatibility) => match incompatibility {
157151
IncompatibleSource::NoBuild => format!("have {self}"),
@@ -202,9 +196,6 @@ impl Display for IncompatibleDist {
202196
IncompatibleWheel::RequiresPython(python, _) => {
203197
write!(f, "Python {python}")
204198
}
205-
IncompatibleWheel::MissingPlatform(platform) => {
206-
write!(f, "no {platform}-compatible wheels")
207-
}
208199
},
209200
Self::Source(incompatibility) => match incompatibility {
210201
IncompatibleSource::NoBuild => f.write_str("no usable wheels"),
@@ -257,8 +248,6 @@ pub enum IncompatibleWheel {
257248
Yanked(Yanked),
258249
/// The use of binary wheels is disabled.
259250
NoBinary,
260-
/// The distribution is missing support for the target platform.
261-
MissingPlatform(String),
262251
}
263252

264253
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -618,40 +607,28 @@ impl IncompatibleWheel {
618607
timestamp_other < timestamp_self
619608
}
620609
},
621-
Self::MissingPlatform(_)
622-
| Self::NoBinary
623-
| Self::RequiresPython(_, _)
624-
| Self::Tag(_)
625-
| Self::Yanked(_) => true,
610+
Self::NoBinary | Self::RequiresPython(_, _) | Self::Tag(_) | Self::Yanked(_) => {
611+
true
612+
}
626613
},
627614
Self::Tag(tag_self) => match other {
628615
Self::ExcludeNewer(_) => false,
629616
Self::Tag(tag_other) => tag_self > tag_other,
630-
Self::MissingPlatform(_)
631-
| Self::NoBinary
632-
| Self::RequiresPython(_, _)
633-
| Self::Yanked(_) => true,
617+
Self::NoBinary | Self::RequiresPython(_, _) | Self::Yanked(_) => true,
634618
},
635619
Self::RequiresPython(_, _) => match other {
636620
Self::ExcludeNewer(_) | Self::Tag(_) => false,
637621
// Version specifiers cannot be reasonably compared
638622
Self::RequiresPython(_, _) => false,
639-
Self::MissingPlatform(_) | Self::NoBinary | Self::Yanked(_) => true,
623+
Self::NoBinary | Self::Yanked(_) => true,
640624
},
641625
Self::Yanked(_) => match other {
642626
Self::ExcludeNewer(_) | Self::Tag(_) | Self::RequiresPython(_, _) => false,
643627
// Yanks with a reason are more helpful for errors
644628
Self::Yanked(yanked_other) => matches!(yanked_other, Yanked::Reason(_)),
645-
Self::MissingPlatform(_) | Self::NoBinary => true,
646-
},
647-
Self::NoBinary => match other {
648-
Self::MissingPlatform(_) => true,
649-
_ => false,
650-
},
651-
Self::MissingPlatform(platform_other) => match other {
652-
Self::MissingPlatform(platform_self) => platform_self > platform_other,
653-
_ => false,
629+
Self::NoBinary => true,
654630
},
631+
Self::NoBinary => false,
655632
}
656633
}
657634
}

crates/uv-resolver/src/pubgrub/package.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ impl PubGrubPackage {
228228
}
229229
}
230230

231-
/// Returns `true` if this PubGrub package is the root package.
232-
pub(crate) fn is_root(&self) -> bool {
233-
matches!(&**self, PubGrubPackageInner::Root(_))
234-
}
235-
236231
/// Returns `true` if this PubGrub package is a proxy package.
237232
pub(crate) fn is_proxy(&self) -> bool {
238233
matches!(

crates/uv-resolver/src/resolver/availability.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ use std::fmt::{Display, Formatter};
33
use uv_distribution_types::IncompatibleDist;
44
use uv_pep440::{Version, VersionSpecifiers};
55

6-
use crate::resolver::MetadataUnavailable;
7-
use crate::ResolverEnvironment;
6+
use crate::resolver::{MetadataUnavailable, VersionFork};
87

98
/// The reason why a package or a version cannot be used.
109
#[derive(Debug, Clone, Eq, PartialEq)]
@@ -170,6 +169,6 @@ pub(crate) enum ResolverVersion {
170169
Unavailable(Version, UnavailableVersion),
171170
/// A usable version
172171
Unforked(Version),
173-
/// A set of forks.
174-
Forked(Vec<ResolverEnvironment>),
172+
/// A set of forks, optionally with resolved versions
173+
Forked(Vec<VersionFork>),
175174
}

crates/uv-resolver/src/resolver/environment.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ pub(crate) fn fork_version_by_python_requirement(
559559
pub(crate) fn fork_version_by_marker(
560560
env: &ResolverEnvironment,
561561
marker: MarkerTree,
562-
) -> Vec<ResolverEnvironment> {
562+
) -> Option<(ResolverEnvironment, ResolverEnvironment)> {
563563
let Kind::Universal {
564564
markers: ref env_marker,
565565
..
@@ -584,20 +584,18 @@ pub(crate) fn fork_version_by_marker(
584584
// `sys_platform == 'win32'`, return an empty list, since the following isn't satisfiable:
585585
//
586586
// python_version >= '3.10' and sys_platform == 'linux' and sys_platform == 'win32'
587-
588-
let mut envs = vec![];
589587
if env_marker.is_disjoint(marker) {
590-
return vec![];
588+
return None;
591589
}
592-
envs.push(env.narrow_environment(marker));
590+
let with_marker = env.narrow_environment(marker);
593591

594592
let complement = marker.negate();
595593
if env_marker.is_disjoint(complement) {
596-
return vec![];
594+
return None;
597595
}
598-
envs.push(env.narrow_environment(complement));
596+
let without_marker = env.narrow_environment(complement);
599597

600-
envs
598+
Some((with_marker, without_marker))
601599
}
602600

603601
#[cfg(test)]

0 commit comments

Comments
 (0)