Skip to content

Commit

Permalink
graalpy: Bail out if graalpy version is less than what we support
Browse files Browse the repository at this point in the history
  • Loading branch information
timfel committed Mar 25, 2024
1 parent 366a3b2 commit bca1c5a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ use crate::{
/// Minimum Python version PyO3 supports.
const MINIMUM_SUPPORTED_VERSION: PythonVersion = PythonVersion { major: 3, minor: 7 };

/// GraalPy may implement the same CPython version over multiple releases.
const MINIMUM_SUPPORTED_VERSION_GRAALPY: PythonVersion = PythonVersion { major: 24, minor: 0 };

/// Maximum Python version that can be used as minimum required Python version with abi3.
const ABI3_MAX_MINOR: u8 = 12;

Expand Down Expand Up @@ -204,6 +207,11 @@ from sysconfig import get_config_var, get_platform
PYPY = platform.python_implementation() == "PyPy"
GRAALPY = platform.python_implementation() == "GraalVM"
if GRAALPY:
graalpy_ver = map(int, __graalpython__.get_graalvm_version().split('.'));
print("graalpy_major", next(graalpy_ver))
print("graalpy_minor", next(graalpy_ver))
# sys.base_prefix is missing on Python versions older than 3.3; this allows the script to continue
# so that the version mismatch can be reported in a nicer way later.
base_prefix = getattr(sys, "base_prefix", None)
Expand Down Expand Up @@ -250,6 +258,26 @@ print("ext_suffix", get_config_var("EXT_SUFFIX"))
interpreter.as_ref().display()
);

match map.get("graalpy_major") {
Some(value) => {
let graalpy_version = PythonVersion {
major: value
.parse()
.context("failed to parse GraalPy major version")?,
minor: map["graalpy_minor"]
.parse()
.context("failed to parse GraalPy minor version")?,
};
ensure!(
graalpy_version >= MINIMUM_SUPPORTED_VERSION_GRAALPY,
"At least GraalPy version {} needed, got {}",
MINIMUM_SUPPORTED_VERSION_GRAALPY,
graalpy_version
);
},
None => ()
};

let shared = map["shared"].as_str() == "True";

let version = PythonVersion {
Expand Down

0 comments on commit bca1c5a

Please sign in to comment.