Skip to content

Commit 40efe61

Browse files
Fix GraalPy abi tag parsing and discovery (#12154)
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary There were no GraalPy binary wheels were available when uv support was added, and thus the abi tag was never tested against actual packages. Now that GraalPy publishes binary wheels to https://www.graalvm.org/python/wheels/ we noticed the abi tag was incorrect and the version info incorrectly determined. ## Test Plan I tested manually: ``` > target/debug/uv venv --python graalpy testvenv Using GraalPy 3.11.7 interpreter at: /home/tim/.pyenv/versions/graalpy-24.1.1/bin/graalpy Creating virtual environment at: testvenv Activate with: source testvenv/bin/activate > cat <<EOF> uv.toml > [[index]] > url = "https://www.graalvm.org/python/wheels/" > EOF > target/debug/uv -v pip install psutil warning: Found both a `uv.toml` file and a `[tool.uv]` section in an adjacent `pyproject.toml`. The `[tool.uv]` section will be ignored in favor of the `uv.toml` file. DEBUG uv 0.6.6+3 (be87255 2025-03-13) DEBUG Searching for default Python interpreter in virtual environments DEBUG Found `graalpy-3.11.7-linux-x86_64-gnu` at `/home/tim/dev/uv/.venv/bin/python3` (virtual environment) DEBUG Using Python 3.11.7 environment at: .venv DEBUG Acquired lock for `.venv` DEBUG At least one requirement is not satisfied: psutil DEBUG Using request timeout of 30s DEBUG Solving with installed Python version: 3.11.7 DEBUG Solving with target Python version: >=3.11.7 DEBUG Adding direct dependency: psutil* DEBUG Found fresh response for: https://www.graalvm.org/python/wheels/psutil/ DEBUG Searching for a compatible version of psutil (*) DEBUG Selecting: psutil==5.9.8 [compatible] (psutil-5.9.8-graalpy311-graalpy241_311_native-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl) DEBUG No cache entry for: https://gds.oracle.com/download/graalpy-wheels/psutil-5.9.8-graalpy311-graalpy241_311_native-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl DEBUG Tried 1 versions: psutil 1 DEBUG marker environment resolution took 0.968s Resolved 1 package in 971ms DEBUG Identified uncached distribution: psutil==5.9.8 DEBUG No cache entry for: https://gds.oracle.com/download/graalpy-wheels/psutil-5.9.8-graalpy311-graalpy241_311_native-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl Prepared 1 package in 268ms Installed 1 package in 28ms + psutil==5.9.8 DEBUG Released lock at `/home/tim/dev/uv/.venv/.lock` ``` --------- Co-authored-by: Charlie Marsh <[email protected]>
1 parent 3188d99 commit 40efe61

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

crates/uv-platform-tags/src/abi_tag.rs

+19-30
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum AbiTag {
3434
python_version: Option<(u8, u8)>,
3535
implementation_version: (u8, u8),
3636
},
37-
/// Ex) `graalpy310_graalpy240_310_native`
37+
/// Ex) `graalpy240_310_native`
3838
GraalPy {
3939
python_version: (u8, u8),
4040
implementation_version: (u8, u8),
@@ -109,7 +109,7 @@ impl std::fmt::Display for AbiTag {
109109
} => {
110110
write!(
111111
f,
112-
"graalpy{py_major}{py_minor}_graalpy{impl_major}{impl_minor}_{py_major}{py_minor}_native"
112+
"graalpy{impl_major}{impl_minor}_{py_major}{py_minor}_native"
113113
)
114114
}
115115
Self::Pyston {
@@ -237,29 +237,21 @@ impl FromStr for AbiTag {
237237
})
238238
}
239239
} else if let Some(rest) = s.strip_prefix("graalpy") {
240-
// Ex) `graalpy310_graalpy240_310_native`
241-
let version_end = rest
242-
.find('_')
243-
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
244-
implementation: "GraalPy",
245-
tag: s.to_string(),
246-
})?;
247-
let version_str = &rest[..version_end];
248-
let (major, minor) = parse_python_version(version_str, "GraalPy", s)?;
249-
let rest = rest[version_end + 1..]
250-
.strip_prefix("graalpy")
251-
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
252-
implementation: "GraalPy",
253-
tag: s.to_string(),
254-
})?;
255-
let version_end = rest
256-
.find('_')
257-
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
258-
implementation: "GraalPy",
259-
tag: s.to_string(),
260-
})?;
261-
let rest = &rest[..version_end];
262-
let (impl_major, impl_minor) = parse_impl_version(rest, "GraalPy", s)?;
240+
// Ex) `graalpy240_310_native`
241+
let (impl_ver_str, rest) =
242+
rest.split_once('_')
243+
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
244+
implementation: "GraalPy",
245+
tag: s.to_string(),
246+
})?;
247+
let (impl_major, impl_minor) = parse_impl_version(impl_ver_str, "GraalPy", s)?;
248+
let (py_ver_str, _) =
249+
rest.split_once('_')
250+
.ok_or_else(|| ParseAbiTagError::InvalidFormat {
251+
implementation: "GraalPy",
252+
tag: s.to_string(),
253+
})?;
254+
let (major, minor) = parse_python_version(py_ver_str, "GraalPy", s)?;
263255
Ok(Self::GraalPy {
264256
python_version: (major, minor),
265257
implementation_version: (impl_major, impl_minor),
@@ -434,11 +426,8 @@ mod tests {
434426
python_version: (3, 10),
435427
implementation_version: (2, 40),
436428
};
437-
assert_eq!(
438-
AbiTag::from_str("graalpy310_graalpy240_310_native"),
439-
Ok(tag)
440-
);
441-
assert_eq!(tag.to_string(), "graalpy310_graalpy240_310_native");
429+
assert_eq!(AbiTag::from_str("graalpy240_310_native"), Ok(tag));
430+
assert_eq!(tag.to_string(), "graalpy240_310_native");
442431

443432
assert_eq!(
444433
AbiTag::from_str("graalpy310"),

crates/uv-platform-tags/src/tags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl Implementation {
395395
python_version: Some(python_version),
396396
implementation_version,
397397
},
398-
// Ex) `graalpy310_graalpy240_310_native
398+
// Ex) `graalpy240_310_native
399399
Self::GraalPy => AbiTag::GraalPy {
400400
python_version,
401401
implementation_version,

crates/uv-python/python/get_interpreter_info.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,18 @@ def format_full_version(info):
3434
sys.exit(0)
3535

3636
if hasattr(sys, "implementation"):
37-
implementation_version = format_full_version(sys.implementation.version)
3837
implementation_name = sys.implementation.name
38+
if implementation_name == "graalpy":
39+
# GraalPy reports the CPython version as sys.implementation.version,
40+
# so we need to discover the GraalPy version from the cache_tag
41+
import re
42+
implementation_version = re.sub(
43+
r"graalpy(\d)(\d+)-\d+",
44+
r"\1.\2",
45+
sys.implementation.cache_tag
46+
)
47+
else:
48+
implementation_version = format_full_version(sys.implementation.version)
3949
else:
4050
implementation_version = "0"
4151
implementation_name = ""

crates/uv/tests/it/common/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use uv_static::EnvVars;
3232
// Exclude any packages uploaded after this date.
3333
static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z";
3434

35-
pub const PACKSE_VERSION: &str = "0.3.45";
35+
pub const PACKSE_VERSION: &str = "0.3.46";
3636

3737
/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
3838
/// to prevent dependency confusion attacks against our test suite.

crates/uv/tests/it/pip_install_scenarios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4091,7 +4091,7 @@ fn no_sdist_no_wheels_with_matching_abi() {
40914091
╰─▶ Because only package-a==1.0.0 is available and package-a==1.0.0 has no wheels with a matching Python ABI tag (e.g., `cp38`), we can conclude that all versions of package-a cannot be used.
40924092
And because you require package-a, we can conclude that your requirements are unsatisfiable.
40934093
4094-
hint: You require CPython 3.8 (`cp38`), but we only found wheels for `package-a` (v1.0.0) with the following Python ABI tag: `graalpy310_graalpy240_310_native`
4094+
hint: You require CPython 3.8 (`cp38`), but we only found wheels for `package-a` (v1.0.0) with the following Python ABI tag: `graalpy240_310_native`
40954095
"###);
40964096

40974097
assert_not_installed(

0 commit comments

Comments
 (0)