Implement ordering for Python architectures to prefer native installations (#13709)
Resolves https://github.com/astral-sh/uv/pull/13474#discussion_r2112586405 This kind of dynamic ordering freaks me out a little, but I think it's probably the best solution and is static at compile-time. Currently, we're just sorting by the stringified representation! which is just convenient for reproducibility, but we rely on these orderings for prioritization in discovery.
This commit is contained in:
@@ -483,8 +483,10 @@ impl Ord for PythonInstallationKey {
|
||||
.cmp(&other.implementation)
|
||||
.then_with(|| self.version().cmp(&other.version()))
|
||||
.then_with(|| self.os.to_string().cmp(&other.os.to_string()))
|
||||
.then_with(|| self.arch.to_string().cmp(&other.arch.to_string()))
|
||||
// Architectures are sorted in preferred order, with native architectures first
|
||||
.then_with(|| self.arch.cmp(&other.arch).reverse())
|
||||
.then_with(|| self.libc.to_string().cmp(&other.libc.to_string()))
|
||||
.then_with(|| self.variant.cmp(&other.variant).reverse()) // we want Default to come first
|
||||
// Python variants are sorted in preferred order, with `Default` first
|
||||
.then_with(|| self.variant.cmp(&other.variant).reverse())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user