@@ -32,6 +32,9 @@ use crate::{
3232/// Minimum Python version PyO3 supports.
3333const 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 { major : 24 , minor : 0 } ;
37+
3538/// Maximum Python version that can be used as minimum required Python version with abi3.
3639const ABI3_MAX_MINOR : u8 = 12 ;
3740
@@ -204,6 +207,11 @@ from sysconfig import get_config_var, get_platform
204207PYPY = platform.python_implementation() == "PyPy"
205208GRAALPY = platform.python_implementation() == "GraalVM"
206209
210+ if GRAALPY:
211+ graalpy_ver = map(int, __graalpython__.get_graalvm_version().split('.'));
212+ print("graalpy_major", next(graalpy_ver))
213+ print("graalpy_minor", next(graalpy_ver))
214+
207215# sys.base_prefix is missing on Python versions older than 3.3; this allows the script to continue
208216# so that the version mismatch can be reported in a nicer way later.
209217base_prefix = getattr(sys, "base_prefix", None)
@@ -250,6 +258,26 @@ print("ext_suffix", get_config_var("EXT_SUFFIX"))
250258 interpreter. as_ref( ) . display( )
251259 ) ;
252260
261+ match map. get ( "graalpy_major" ) {
262+ Some ( value) => {
263+ let graalpy_version = PythonVersion {
264+ major : value
265+ . parse ( )
266+ . context ( "failed to parse GraalPy major version" ) ?,
267+ minor : map[ "graalpy_minor" ]
268+ . parse ( )
269+ . context ( "failed to parse GraalPy minor version" ) ?,
270+ } ;
271+ ensure ! (
272+ graalpy_version >= MINIMUM_SUPPORTED_VERSION_GRAALPY ,
273+ "At least GraalPy version {} needed, got {}" ,
274+ MINIMUM_SUPPORTED_VERSION_GRAALPY ,
275+ graalpy_version
276+ ) ;
277+ } ,
278+ None => ( )
279+ } ;
280+
253281 let shared = map[ "shared" ] . as_str ( ) == "True" ;
254282
255283 let version = PythonVersion {
0 commit comments