mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-02 06:51:14 +00:00
Rename all instances of Cpython
to CPython
(#3702)
This commit is contained in:
parent
d313d9b1fa
commit
19df1a4372
6 changed files with 475 additions and 466 deletions
|
@ -18,7 +18,7 @@ pub enum TagsError {
|
||||||
#[error("Invalid priority: `{0}`")]
|
#[error("Invalid priority: `{0}`")]
|
||||||
InvalidPriority(usize, #[source] std::num::TryFromIntError),
|
InvalidPriority(usize, #[source] std::num::TryFromIntError),
|
||||||
#[error("Only CPython can be freethreading, not: {0}")]
|
#[error("Only CPython can be freethreading, not: {0}")]
|
||||||
GilIsACpythonProblem(String),
|
GilIsACPythonProblem(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd, Clone)]
|
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd, Clone)]
|
||||||
|
@ -355,7 +355,7 @@ impl Implementation {
|
||||||
|
|
||||||
fn parse(name: &str, gil_disabled: bool) -> Result<Self, TagsError> {
|
fn parse(name: &str, gil_disabled: bool) -> Result<Self, TagsError> {
|
||||||
if gil_disabled && name != "cpython" {
|
if gil_disabled && name != "cpython" {
|
||||||
return Err(TagsError::GilIsACpythonProblem(name.to_string()));
|
return Err(TagsError::GilIsACPythonProblem(name.to_string()));
|
||||||
}
|
}
|
||||||
match name {
|
match name {
|
||||||
// Known and supported implementations.
|
// Known and supported implementations.
|
||||||
|
|
|
@ -1176,12 +1176,12 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
InterpreterRequest::parse("cpython"),
|
InterpreterRequest::parse("cpython"),
|
||||||
InterpreterRequest::Implementation(ImplementationName::Cpython)
|
InterpreterRequest::Implementation(ImplementationName::CPython)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
InterpreterRequest::parse("cpython3.12.2"),
|
InterpreterRequest::parse("cpython3.12.2"),
|
||||||
InterpreterRequest::ImplementationVersion(
|
InterpreterRequest::ImplementationVersion(
|
||||||
ImplementationName::Cpython,
|
ImplementationName::CPython,
|
||||||
VersionRequest::from_str("3.12.2").unwrap()
|
VersionRequest::from_str("3.12.2").unwrap()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,18 +12,18 @@ pub enum Error {
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
||||||
pub enum ImplementationName {
|
pub enum ImplementationName {
|
||||||
Cpython,
|
CPython,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImplementationName {
|
impl ImplementationName {
|
||||||
pub(crate) fn iter() -> impl Iterator<Item = &'static ImplementationName> {
|
pub(crate) fn iter() -> impl Iterator<Item = &'static ImplementationName> {
|
||||||
static NAMES: &[ImplementationName] = &[ImplementationName::Cpython];
|
static NAMES: &[ImplementationName] = &[ImplementationName::CPython];
|
||||||
NAMES.iter()
|
NAMES.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_str(&self) -> &str {
|
pub fn as_str(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Self::Cpython => "cpython",
|
Self::CPython => "cpython",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ impl FromStr for ImplementationName {
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s.to_ascii_lowercase().as_str() {
|
match s.to_ascii_lowercase().as_str() {
|
||||||
"cpython" => Ok(Self::Cpython),
|
"cpython" => Ok(Self::CPython),
|
||||||
_ => Err(Error::UnknownImplementation(s.to_string())),
|
_ => Err(Error::UnknownImplementation(s.to_string())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl PythonDownloadRequest {
|
||||||
|
|
||||||
pub fn fill(mut self) -> Result<Self, Error> {
|
pub fn fill(mut self) -> Result<Self, Error> {
|
||||||
if self.implementation.is_none() {
|
if self.implementation.is_none() {
|
||||||
self.implementation = Some(ImplementationName::Cpython);
|
self.implementation = Some(ImplementationName::CPython);
|
||||||
}
|
}
|
||||||
if self.arch.is_none() {
|
if self.arch.is_none() {
|
||||||
self.arch = Some(Arch::from_env()?);
|
self.arch = Some(Arch::from_env()?);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,10 +33,19 @@ except ImportError:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def prepare_name(name: str) -> str:
|
||||||
|
match name:
|
||||||
|
case "cpython":
|
||||||
|
return "CPython"
|
||||||
|
case _:
|
||||||
|
raise ValueError(f"Unknown implementation name: {name}")
|
||||||
|
|
||||||
|
|
||||||
def prepare_value(value: dict) -> dict:
|
def prepare_value(value: dict) -> dict:
|
||||||
# Convert fields from snake case to camel case for enums
|
# Convert fields from snake case to camel case for enums
|
||||||
for key in ["arch", "os", "libc", "name"]:
|
for key in ["arch", "os", "libc"]:
|
||||||
value[key] = value[key].title()
|
value[key] = value[key].title()
|
||||||
|
value["name"] = prepare_name(value["name"])
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue