mirror of https://github.com/astral-sh/uv
Correct Pyston tag format (#10580)
## Summary Empirically, it looks like the format here is slightly different than what we had in the code? Our integration test caught it.
This commit is contained in:
parent
5c91217488
commit
3fd090b373
|
|
@ -39,11 +39,8 @@ pub enum AbiTag {
|
||||||
python_version: (u8, u8),
|
python_version: (u8, u8),
|
||||||
implementation_version: (u8, u8),
|
implementation_version: (u8, u8),
|
||||||
},
|
},
|
||||||
/// Ex) `pyston38-pyston_23`
|
/// Ex) `pyston_23_x86_64_linux_gnu`
|
||||||
Pyston {
|
Pyston { implementation_version: (u8, u8) },
|
||||||
python_version: (u8, u8),
|
|
||||||
implementation_version: (u8, u8),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for AbiTag {
|
impl std::fmt::Display for AbiTag {
|
||||||
|
|
@ -82,13 +79,9 @@ impl std::fmt::Display for AbiTag {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Self::Pyston {
|
Self::Pyston {
|
||||||
python_version: (py_major, py_minor),
|
|
||||||
implementation_version: (impl_major, impl_minor),
|
implementation_version: (impl_major, impl_minor),
|
||||||
} => {
|
} => {
|
||||||
write!(
|
write!(f, "pyston_{impl_major}{impl_minor}_x86_64_linux_gnu")
|
||||||
f,
|
|
||||||
"pyston{py_major}{py_minor}-pyston_{impl_major}{impl_minor}"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -229,24 +222,21 @@ impl FromStr for AbiTag {
|
||||||
implementation_version: (impl_major, impl_minor),
|
implementation_version: (impl_major, impl_minor),
|
||||||
})
|
})
|
||||||
} else if let Some(rest) = s.strip_prefix("pyston") {
|
} else if let Some(rest) = s.strip_prefix("pyston") {
|
||||||
// Ex) `pyston38-pyston_23`
|
// Ex) `pyston_23_x86_64_linux_gnu`
|
||||||
let version_end = rest
|
let rest = rest
|
||||||
.find('-')
|
.strip_prefix("_")
|
||||||
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
|
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
|
||||||
implementation: "Pyston",
|
implementation: "Pyston",
|
||||||
tag: s.to_string(),
|
tag: s.to_string(),
|
||||||
})?;
|
})?;
|
||||||
let version_str = &rest[..version_end];
|
let rest = rest.strip_suffix("_x86_64_linux_gnu").ok_or_else(|| {
|
||||||
let (major, minor) = parse_python_version(version_str, "Pyston", s)?;
|
ParseAbiTagError::InvalidFormat {
|
||||||
let rest = rest[version_end + 1..]
|
|
||||||
.strip_prefix("pyston_")
|
|
||||||
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
|
|
||||||
implementation: "Pyston",
|
implementation: "Pyston",
|
||||||
tag: s.to_string(),
|
tag: s.to_string(),
|
||||||
|
}
|
||||||
})?;
|
})?;
|
||||||
let (impl_major, impl_minor) = parse_impl_version(rest, "Pyston", s)?;
|
let (impl_major, impl_minor) = parse_impl_version(rest, "Pyston", s)?;
|
||||||
Ok(Self::Pyston {
|
Ok(Self::Pyston {
|
||||||
python_version: (major, minor),
|
|
||||||
implementation_version: (impl_major, impl_minor),
|
implementation_version: (impl_major, impl_minor),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -426,31 +416,23 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn pyston_abi() {
|
fn pyston_abi() {
|
||||||
let tag = AbiTag::Pyston {
|
let tag = AbiTag::Pyston {
|
||||||
python_version: (3, 8),
|
|
||||||
implementation_version: (2, 3),
|
implementation_version: (2, 3),
|
||||||
};
|
};
|
||||||
assert_eq!(AbiTag::from_str("pyston38-pyston_23"), Ok(tag));
|
assert_eq!(AbiTag::from_str("pyston_23_x86_64_linux_gnu"), Ok(tag));
|
||||||
assert_eq!(tag.to_string(), "pyston38-pyston_23");
|
assert_eq!(tag.to_string(), "pyston_23_x86_64_linux_gnu");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
AbiTag::from_str("pyston38"),
|
AbiTag::from_str("pyston23_x86_64_linux_gnu"),
|
||||||
Err(ParseAbiTagError::InvalidFormat {
|
Err(ParseAbiTagError::InvalidFormat {
|
||||||
implementation: "Pyston",
|
implementation: "Pyston",
|
||||||
tag: "pyston38".to_string()
|
tag: "pyston23_x86_64_linux_gnu".to_string()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
AbiTag::from_str("pyston38_23"),
|
AbiTag::from_str("pyston_XY_x86_64_linux_gnu"),
|
||||||
Err(ParseAbiTagError::InvalidFormat {
|
|
||||||
implementation: "Pyston",
|
|
||||||
tag: "pyston38_23".to_string()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
AbiTag::from_str("pyston38-pyston_XY"),
|
|
||||||
Err(ParseAbiTagError::InvalidImplMajorVersion {
|
Err(ParseAbiTagError::InvalidImplMajorVersion {
|
||||||
implementation: "Pyston",
|
implementation: "Pyston",
|
||||||
tag: "pyston38-pyston_XY".to_string()
|
tag: "pyston_XY_x86_64_linux_gnu".to_string()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ pub enum LanguageTag {
|
||||||
PyPy { python_version: (u8, u8) },
|
PyPy { python_version: (u8, u8) },
|
||||||
/// Ex) `graalpy310`
|
/// Ex) `graalpy310`
|
||||||
GraalPy { python_version: (u8, u8) },
|
GraalPy { python_version: (u8, u8) },
|
||||||
/// Ex) `pt38`
|
/// Ex) `pyston38`
|
||||||
Pyston { python_version: (u8, u8) },
|
Pyston { python_version: (u8, u8) },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ impl std::fmt::Display for LanguageTag {
|
||||||
Self::Pyston {
|
Self::Pyston {
|
||||||
python_version: (major, minor),
|
python_version: (major, minor),
|
||||||
} => {
|
} => {
|
||||||
write!(f, "pt{major}{minor}")
|
write!(f, "pyston{major}{minor}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,14 @@ impl FromStr for LanguageTag {
|
||||||
if s == "none" {
|
if s == "none" {
|
||||||
Ok(Self::None)
|
Ok(Self::None)
|
||||||
} else if let Some(py) = s.strip_prefix("py") {
|
} else if let Some(py) = s.strip_prefix("py") {
|
||||||
if py.len() == 1 {
|
match py.len() {
|
||||||
|
0 => {
|
||||||
|
return Err(ParseLanguageTagError::MissingMajorVersion {
|
||||||
|
implementation: "Python",
|
||||||
|
tag: s.to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
1 => {
|
||||||
// Ex) `py3`
|
// Ex) `py3`
|
||||||
let major = py
|
let major = py
|
||||||
.chars()
|
.chars()
|
||||||
|
|
@ -126,14 +133,27 @@ impl FromStr for LanguageTag {
|
||||||
tag: s.to_string(),
|
tag: s.to_string(),
|
||||||
})? as u8;
|
})? as u8;
|
||||||
Ok(Self::Python { major, minor: None })
|
Ok(Self::Python { major, minor: None })
|
||||||
} else {
|
}
|
||||||
// Ex) `py39`
|
2 | 3 => {
|
||||||
|
// Ex) `py39`, `py310`
|
||||||
let (major, minor) = parse_python_version(py, "Python", s)?;
|
let (major, minor) = parse_python_version(py, "Python", s)?;
|
||||||
Ok(Self::Python {
|
Ok(Self::Python {
|
||||||
major,
|
major,
|
||||||
minor: Some(minor),
|
minor: Some(minor),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
_ => {
|
||||||
|
if let Some(pyston) = py.strip_prefix("ston") {
|
||||||
|
// Ex) `pyston38`
|
||||||
|
let (major, minor) = parse_python_version(pyston, "Pyston", s)?;
|
||||||
|
Ok(Self::Pyston {
|
||||||
|
python_version: (major, minor),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(ParseLanguageTagError::UnknownFormat(s.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if let Some(cp) = s.strip_prefix("cp") {
|
} else if let Some(cp) = s.strip_prefix("cp") {
|
||||||
// Ex) `cp39`
|
// Ex) `cp39`
|
||||||
let (major, minor) = parse_python_version(cp, "CPython", s)?;
|
let (major, minor) = parse_python_version(cp, "CPython", s)?;
|
||||||
|
|
@ -152,12 +172,6 @@ impl FromStr for LanguageTag {
|
||||||
Ok(Self::GraalPy {
|
Ok(Self::GraalPy {
|
||||||
python_version: (major, minor),
|
python_version: (major, minor),
|
||||||
})
|
})
|
||||||
} else if let Some(pt) = s.strip_prefix("pt") {
|
|
||||||
// Ex) `pt38`
|
|
||||||
let (major, minor) = parse_python_version(pt, "Pyston", s)?;
|
|
||||||
Ok(Self::Pyston {
|
|
||||||
python_version: (major, minor),
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
Err(ParseLanguageTagError::UnknownFormat(s.to_string()))
|
Err(ParseLanguageTagError::UnknownFormat(s.to_string()))
|
||||||
}
|
}
|
||||||
|
|
@ -340,28 +354,28 @@ mod tests {
|
||||||
let tag = LanguageTag::Pyston {
|
let tag = LanguageTag::Pyston {
|
||||||
python_version: (3, 8),
|
python_version: (3, 8),
|
||||||
};
|
};
|
||||||
assert_eq!(LanguageTag::from_str("pt38"), Ok(tag));
|
assert_eq!(LanguageTag::from_str("pyston38"), Ok(tag));
|
||||||
assert_eq!(tag.to_string(), "pt38");
|
assert_eq!(tag.to_string(), "pyston38");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
LanguageTag::from_str("pt"),
|
LanguageTag::from_str("pyston"),
|
||||||
Err(ParseLanguageTagError::MissingMajorVersion {
|
Err(ParseLanguageTagError::MissingMajorVersion {
|
||||||
implementation: "Pyston",
|
implementation: "Pyston",
|
||||||
tag: "pt".to_string()
|
tag: "pyston".to_string()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
LanguageTag::from_str("ptX"),
|
LanguageTag::from_str("pystonX"),
|
||||||
Err(ParseLanguageTagError::InvalidMajorVersion {
|
Err(ParseLanguageTagError::InvalidMajorVersion {
|
||||||
implementation: "Pyston",
|
implementation: "Pyston",
|
||||||
tag: "ptX".to_string()
|
tag: "pystonX".to_string()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
LanguageTag::from_str("pt3X"),
|
LanguageTag::from_str("pyston3X"),
|
||||||
Err(ParseLanguageTagError::InvalidMinorVersion {
|
Err(ParseLanguageTagError::InvalidMinorVersion {
|
||||||
implementation: "Pyston",
|
implementation: "Pyston",
|
||||||
tag: "pt3X".to_string()
|
tag: "pyston3X".to_string()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ impl Implementation {
|
||||||
Self::PyPy => LanguageTag::PyPy { python_version },
|
Self::PyPy => LanguageTag::PyPy { python_version },
|
||||||
// Ex) `graalpy310`
|
// Ex) `graalpy310`
|
||||||
Self::GraalPy => LanguageTag::GraalPy { python_version },
|
Self::GraalPy => LanguageTag::GraalPy { python_version },
|
||||||
// Ex) `pt38``
|
// Ex) `pyston38`
|
||||||
Self::Pyston => LanguageTag::Pyston { python_version },
|
Self::Pyston => LanguageTag::Pyston { python_version },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -398,9 +398,8 @@ impl Implementation {
|
||||||
python_version,
|
python_version,
|
||||||
implementation_version,
|
implementation_version,
|
||||||
},
|
},
|
||||||
// Ex) `pyston38-pyston_23`
|
// Ex) `pyston_23_x86_64_linux`
|
||||||
Self::Pyston => AbiTag::Pyston {
|
Self::Pyston => AbiTag::Pyston {
|
||||||
python_version,
|
|
||||||
implementation_version,
|
implementation_version,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -469,9 +469,6 @@ impl RequiresPython {
|
||||||
} | AbiTag::GraalPy {
|
} | AbiTag::GraalPy {
|
||||||
python_version: (2, ..),
|
python_version: (2, ..),
|
||||||
..
|
..
|
||||||
} | AbiTag::Pyston {
|
|
||||||
python_version: (2, ..),
|
|
||||||
..
|
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
// Python 2 is never allowed.
|
// Python 2 is never allowed.
|
||||||
|
|
@ -487,10 +484,6 @@ impl RequiresPython {
|
||||||
| AbiTag::GraalPy {
|
| AbiTag::GraalPy {
|
||||||
python_version: (3, minor),
|
python_version: (3, minor),
|
||||||
..
|
..
|
||||||
}
|
|
||||||
| AbiTag::Pyston {
|
|
||||||
python_version: (3, minor),
|
|
||||||
..
|
|
||||||
} = abi_tag
|
} = abi_tag
|
||||||
{
|
{
|
||||||
// Ex) If the wheel bound is `3.6`, then it doesn't match `>=3.10`.
|
// Ex) If the wheel bound is `3.6`, then it doesn't match `>=3.10`.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue