mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Prefer stable releases over pre-releases in uv python install
(#12194)
e.g., `uv python install 3` should not install the 3.14 alpha Closes #12184
This commit is contained in:
parent
c55dd0f295
commit
9484e3663c
4 changed files with 116 additions and 9 deletions
|
@ -2294,9 +2294,9 @@ impl VersionRequest {
|
|||
match self {
|
||||
Self::Default => false,
|
||||
Self::Any => true,
|
||||
Self::Major(..) => true,
|
||||
Self::MajorMinor(..) => true,
|
||||
Self::MajorMinorPatch(..) => true,
|
||||
Self::Major(..) => false,
|
||||
Self::MajorMinor(..) => false,
|
||||
Self::MajorMinorPatch(..) => false,
|
||||
Self::MajorMinorPrerelease(..) => true,
|
||||
Self::Range(specifiers, _) => specifiers.iter().any(VersionSpecifier::any_prerelease),
|
||||
}
|
||||
|
|
|
@ -485,13 +485,28 @@ pub enum DownloadResult {
|
|||
|
||||
impl ManagedPythonDownload {
|
||||
/// Return the first [`ManagedPythonDownload`] matching a request, if any.
|
||||
///
|
||||
/// If there is no stable version matching the request, a compatible pre-release version will
|
||||
/// be searched for — even if a pre-release was not explicitly requested.
|
||||
pub fn from_request(
|
||||
request: &PythonDownloadRequest,
|
||||
) -> Result<&'static ManagedPythonDownload, Error> {
|
||||
request
|
||||
.iter_downloads()?
|
||||
.next()
|
||||
.ok_or(Error::NoDownloadFound(request.clone()))
|
||||
if let Some(download) = request.iter_downloads()?.next() {
|
||||
return Ok(download);
|
||||
}
|
||||
|
||||
if !request.allows_prereleases() {
|
||||
if let Some(download) = request
|
||||
.clone()
|
||||
.with_prereleases(true)
|
||||
.iter_downloads()?
|
||||
.next()
|
||||
{
|
||||
return Ok(download);
|
||||
}
|
||||
}
|
||||
|
||||
Err(Error::NoDownloadFound(request.clone()))
|
||||
}
|
||||
|
||||
/// Iterate over all [`ManagedPythonDownload`]s.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue