Skip to content

Commit c5ae4c7

Browse files
committed
graalpy: Bail out if graalpy version is less than what we support
1 parent 366a3b2 commit c5ae4c7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pyo3-build-config/src/impl_.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ use crate::{
3232
/// Minimum Python version PyO3 supports.
3333
const MINIMUM_SUPPORTED_VERSION: PythonVersion = PythonVersion { major: 3, minor: 7 };
3434

35+
/// GraalPy may implement the same CPython version over multiple releases.
36+
const MINIMUM_SUPPORTED_VERSION_GRAALPY: PythonVersion = PythonVersion {
37+
major: 24,
38+
minor: 0,
39+
};
40+
3541
/// Maximum Python version that can be used as minimum required Python version with abi3.
3642
const ABI3_MAX_MINOR: u8 = 12;
3743

@@ -204,6 +210,11 @@ from sysconfig import get_config_var, get_platform
204210
PYPY = platform.python_implementation() == "PyPy"
205211
GRAALPY = platform.python_implementation() == "GraalVM"
206212
213+
if GRAALPY:
214+
graalpy_ver = map(int, __graalpython__.get_graalvm_version().split('.'));
215+
print("graalpy_major", next(graalpy_ver))
216+
print("graalpy_minor", next(graalpy_ver))
217+
207218
# sys.base_prefix is missing on Python versions older than 3.3; this allows the script to continue
208219
# so that the version mismatch can be reported in a nicer way later.
209220
base_prefix = getattr(sys, "base_prefix", None)
@@ -250,6 +261,23 @@ print("ext_suffix", get_config_var("EXT_SUFFIX"))
250261
interpreter.as_ref().display()
251262
);
252263

264+
if let Some(value) = map.get("graalpy_major") {
265+
let graalpy_version = PythonVersion {
266+
major: value
267+
.parse()
268+
.context("failed to parse GraalPy major version")?,
269+
minor: map["graalpy_minor"]
270+
.parse()
271+
.context("failed to parse GraalPy minor version")?,
272+
};
273+
ensure!(
274+
graalpy_version >= MINIMUM_SUPPORTED_VERSION_GRAALPY,
275+
"At least GraalPy version {} needed, got {}",
276+
MINIMUM_SUPPORTED_VERSION_GRAALPY,
277+
graalpy_version
278+
);
279+
};
280+
253281
let shared = map["shared"].as_str() == "True";
254282

255283
let version = PythonVersion {

0 commit comments

Comments
 (0)