mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-17 02:05:01 +00:00
Add support for managed Python 3.13 and update CPython versions (#7263)
Adds support for CPython 3.13.0rc2 Also bumps to the latest patch version of all the other CPython minor versions we support.
This commit is contained in:
parent
0dc1f5db21
commit
0e9870078e
12 changed files with 2989 additions and 70 deletions
|
@ -1,3 +1,4 @@
|
|||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -212,6 +213,7 @@ pub struct PythonInstallationKey {
|
|||
pub(crate) major: u8,
|
||||
pub(crate) minor: u8,
|
||||
pub(crate) patch: u8,
|
||||
pub(crate) prerelease: Cow<'static, str>,
|
||||
pub(crate) os: Os,
|
||||
pub(crate) arch: Arch,
|
||||
pub(crate) libc: Libc,
|
||||
|
@ -223,6 +225,7 @@ impl PythonInstallationKey {
|
|||
major: u8,
|
||||
minor: u8,
|
||||
patch: u8,
|
||||
prerelease: String,
|
||||
os: Os,
|
||||
arch: Arch,
|
||||
libc: Libc,
|
||||
|
@ -232,6 +235,26 @@ impl PythonInstallationKey {
|
|||
major,
|
||||
minor,
|
||||
patch,
|
||||
prerelease: Cow::Owned(prerelease),
|
||||
os,
|
||||
arch,
|
||||
libc,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_version(
|
||||
implementation: LenientImplementationName,
|
||||
version: &PythonVersion,
|
||||
os: Os,
|
||||
arch: Arch,
|
||||
libc: Libc,
|
||||
) -> Self {
|
||||
Self {
|
||||
implementation,
|
||||
major: version.major(),
|
||||
minor: version.minor(),
|
||||
patch: version.patch().unwrap_or_default(),
|
||||
prerelease: Cow::Owned(version.pre().map(|pre| pre.to_string()).unwrap_or_default()),
|
||||
os,
|
||||
arch,
|
||||
libc,
|
||||
|
@ -242,8 +265,12 @@ impl PythonInstallationKey {
|
|||
&self.implementation
|
||||
}
|
||||
|
||||
pub fn version(&self) -> Result<PythonVersion, String> {
|
||||
PythonVersion::from_str(&format!("{}.{}.{}", self.major, self.minor, self.patch))
|
||||
pub fn version(&self) -> PythonVersion {
|
||||
PythonVersion::from_str(&format!(
|
||||
"{}.{}.{}{}",
|
||||
self.major, self.minor, self.patch, self.prerelease
|
||||
))
|
||||
.expect("Python installation keys must have valid Python versions")
|
||||
}
|
||||
|
||||
pub fn arch(&self) -> &Arch {
|
||||
|
@ -263,8 +290,15 @@ impl fmt::Display for PythonInstallationKey {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}-{}.{}.{}-{}-{}-{}",
|
||||
self.implementation, self.major, self.minor, self.patch, self.os, self.arch, self.libc
|
||||
"{}-{}.{}.{}{}-{}-{}-{}",
|
||||
self.implementation,
|
||||
self.major,
|
||||
self.minor,
|
||||
self.patch,
|
||||
self.prerelease,
|
||||
self.os,
|
||||
self.arch,
|
||||
self.libc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -298,28 +332,16 @@ impl FromStr for PythonInstallationKey {
|
|||
PythonInstallationKeyError::ParseError(key.to_string(), format!("invalid libc: {err}"))
|
||||
})?;
|
||||
|
||||
let [major, minor, patch] = version
|
||||
.splitn(3, '.')
|
||||
.map(str::parse::<u8>)
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|err| {
|
||||
PythonInstallationKeyError::ParseError(
|
||||
key.to_string(),
|
||||
format!("invalid Python version: {err}"),
|
||||
)
|
||||
})?[..]
|
||||
else {
|
||||
return Err(PythonInstallationKeyError::ParseError(
|
||||
let version = PythonVersion::from_str(version).map_err(|err| {
|
||||
PythonInstallationKeyError::ParseError(
|
||||
key.to_string(),
|
||||
"invalid Python version: expected `<major>.<minor>.<patch>`".to_string(),
|
||||
));
|
||||
};
|
||||
format!("invalid Python version: {err}"),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(Self::new(
|
||||
Ok(Self::new_from_version(
|
||||
implementation,
|
||||
major,
|
||||
minor,
|
||||
patch,
|
||||
&version,
|
||||
os,
|
||||
arch,
|
||||
libc,
|
||||
|
@ -337,12 +359,7 @@ impl Ord for PythonInstallationKey {
|
|||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
self.implementation
|
||||
.cmp(&other.implementation)
|
||||
.then_with(|| {
|
||||
self.major
|
||||
.cmp(&other.major)
|
||||
.then_with(|| self.minor.cmp(&other.minor))
|
||||
.then_with(|| self.patch.cmp(&other.patch))
|
||||
})
|
||||
.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()))
|
||||
.then_with(|| self.libc.to_string().cmp(&other.libc.to_string()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue