Add prerelease compatibility check (#8020)
## Summary Closes #7977. Makes `PythonDownloadRequest` account for the prerelease part if allowed. Also stores the prerelease in `PythonInstallationKey` directly as a `Prerelease` rather than a string. ## Test Plan Correctly picks the relevant prerelease (rather than picking the most recent one): ``` λ cargo run python install 3.13.0rc2 Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s Running `target/debug/uv python install 3.13.0rc2` Searching for Python versions matching: Python 3.13rc2 cpython-3.13.0rc2-macos-aarch64-none ------------------------------ 457.81 KiB/14.73 MiB ^C λ cargo run python install 3.13.0rc3 Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s Running `target/debug/uv python install 3.13.0rc3` Searching for Python versions matching: Python 3.13rc3 Found existing installation for Python 3.13rc3: cpython-3.13.0rc3-macos-aarch64-none ```
This commit is contained in:
@@ -260,8 +260,17 @@ impl PythonDownloadRequest {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If we don't allow pre-releases, don't match a key with a pre-release tag
|
||||
if !self.allows_prereleases() && key.prerelease.is_some() {
|
||||
return false;
|
||||
}
|
||||
if let Some(version) = &self.version {
|
||||
if !version.matches_major_minor_patch(key.major, key.minor, key.patch) {
|
||||
if !version.matches_major_minor_patch_prerelease(
|
||||
key.major,
|
||||
key.minor,
|
||||
key.patch,
|
||||
key.prerelease,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if version.is_freethreaded() {
|
||||
@@ -269,10 +278,6 @@ impl PythonDownloadRequest {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If we don't allow pre-releases, don't match a key with a pre-release tag
|
||||
if !self.allows_prereleases() && !key.prerelease.is_empty() {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user