mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-15 01: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
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,8 @@
|
|||
// Generated with `{{generated_with}}`
|
||||
// From template at `{{generated_from}}`
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub(crate) const PYTHON_DOWNLOADS: &[ManagedPythonDownload] = &[
|
||||
{{#versions}}
|
||||
ManagedPythonDownload {
|
||||
|
@ -10,6 +12,7 @@ pub(crate) const PYTHON_DOWNLOADS: &[ManagedPythonDownload] = &[
|
|||
major: {{value.major}},
|
||||
minor: {{value.minor}},
|
||||
patch: {{value.patch}},
|
||||
prerelease: Cow::Borrowed("{{value.prerelease}}"),
|
||||
implementation: LenientImplementationName::Known(ImplementationName::{{value.name}}),
|
||||
arch: Arch(target_lexicon::Architecture::{{value.arch}}),
|
||||
os: Os(target_lexicon::OperatingSystem::{{value.os}}),
|
||||
|
|
|
@ -529,9 +529,7 @@ impl ManagedPythonDownload {
|
|||
}
|
||||
|
||||
pub fn python_version(&self) -> PythonVersion {
|
||||
self.key
|
||||
.version()
|
||||
.expect("Managed Python downloads should always have valid versions")
|
||||
self.key.version()
|
||||
}
|
||||
|
||||
/// Return the [`Url`] to use when downloading the distribution. If a mirror is set via the
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -155,6 +155,10 @@ impl Interpreter {
|
|||
self.python_major(),
|
||||
self.python_minor(),
|
||||
self.python_patch(),
|
||||
self.python_version()
|
||||
.pre()
|
||||
.map(|pre| pre.to_string())
|
||||
.unwrap_or_default(),
|
||||
self.os(),
|
||||
self.arch(),
|
||||
self.libc(),
|
||||
|
|
|
@ -282,9 +282,7 @@ impl ManagedPythonInstallation {
|
|||
|
||||
/// The [`PythonVersion`] of the toolchain.
|
||||
pub fn version(&self) -> PythonVersion {
|
||||
self.key
|
||||
.version()
|
||||
.expect("Managed Python installations should always have valid versions")
|
||||
self.key.version()
|
||||
}
|
||||
|
||||
pub fn implementation(&self) -> &ImplementationName {
|
||||
|
@ -331,17 +329,13 @@ impl ManagedPythonInstallation {
|
|||
let stdlib = if matches!(self.key.os, Os(target_lexicon::OperatingSystem::Windows)) {
|
||||
self.python_dir().join("Lib")
|
||||
} else {
|
||||
let version = self
|
||||
.key
|
||||
.version()
|
||||
.expect("Managed Python installations should always have valid versions");
|
||||
let python = if matches!(
|
||||
self.key.implementation,
|
||||
LenientImplementationName::Known(ImplementationName::PyPy)
|
||||
) {
|
||||
format!("pypy{}", version.python_version())
|
||||
format!("pypy{}", self.key.version().python_version())
|
||||
} else {
|
||||
format!("python{}", version.python_version())
|
||||
format!("python{}", self.key.version().python_version())
|
||||
};
|
||||
self.python_dir().join("lib").join(python)
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue