mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-24 13:43:45 +00:00
Include pre-release Python versions in uv python list
(#7290)
Follows https://github.com/astral-sh/uv/pull/7278 Closes https://github.com/astral-sh/uv/issues/7280 `uv python list` should show installed pre-release versions, even though we don't select them by default (as defined by #7300 and https://github.com/astral-sh/uv/pull/7278)
This commit is contained in:
parent
ebd73d83f8
commit
c50eb12c51
3 changed files with 27 additions and 8 deletions
|
@ -96,6 +96,10 @@ pub struct PythonDownloadRequest {
|
|||
arch: Option<Arch>,
|
||||
os: Option<Os>,
|
||||
libc: Option<Libc>,
|
||||
|
||||
/// Whether to allow pre-releases or not. If not set, defaults to true if [`Self::version`] is
|
||||
/// not None, and false otherwise.
|
||||
prereleases: Option<bool>,
|
||||
}
|
||||
|
||||
impl PythonDownloadRequest {
|
||||
|
@ -105,6 +109,7 @@ impl PythonDownloadRequest {
|
|||
arch: Option<Arch>,
|
||||
os: Option<Os>,
|
||||
libc: Option<Libc>,
|
||||
prereleases: Option<bool>,
|
||||
) -> Self {
|
||||
Self {
|
||||
version,
|
||||
|
@ -112,6 +117,7 @@ impl PythonDownloadRequest {
|
|||
arch,
|
||||
os,
|
||||
libc,
|
||||
prereleases,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,6 +151,12 @@ impl PythonDownloadRequest {
|
|||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_prereleases(mut self, prereleases: bool) -> Self {
|
||||
self.prereleases = Some(prereleases);
|
||||
self
|
||||
}
|
||||
|
||||
/// Construct a new [`PythonDownloadRequest`] from a [`PythonRequest`] if possible.
|
||||
///
|
||||
/// Returns [`None`] if the request kind is not compatible with a download, e.g., it is
|
||||
|
@ -196,6 +208,7 @@ impl PythonDownloadRequest {
|
|||
Some(Arch::from_env()),
|
||||
Some(Os::from_env()),
|
||||
Some(Libc::from_env()?),
|
||||
None,
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -252,20 +265,22 @@ 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
|
||||
}
|
||||
|
||||
/// Whether this request is satisfied by a Python download.
|
||||
///
|
||||
/// Note that unlike [`Self::satisfied_by_key`], this method will not match a pre-release
|
||||
/// unless a version is included in the request.
|
||||
pub fn satisfied_by_download(&self, download: &ManagedPythonDownload) -> bool {
|
||||
if self.version.is_none() && !download.key().prerelease.is_empty() {
|
||||
return false;
|
||||
}
|
||||
self.satisfied_by_key(download.key())
|
||||
}
|
||||
|
||||
pub fn allows_prereleases(&self) -> bool {
|
||||
self.prereleases.unwrap_or_else(|| self.version.is_some())
|
||||
}
|
||||
|
||||
pub fn satisfied_by_interpreter(&self, interpreter: &Interpreter) -> bool {
|
||||
if let Some(version) = self.version() {
|
||||
if !version.matches_interpreter(interpreter) {
|
||||
|
@ -375,7 +390,7 @@ impl FromStr for PythonDownloadRequest {
|
|||
|
||||
return Err(Error::TooManyParts(s.to_string()));
|
||||
}
|
||||
Ok(Self::new(version, implementation, arch, os, libc))
|
||||
Ok(Self::new(version, implementation, arch, os, libc, None))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue