@@ -12,7 +12,21 @@ use std::io::{BufRead, BufReader};
1212use std:: path:: Path ;
1313
1414const PYPY_ABI_TAG : & str = "pp73" ;
15- const GRAALPY_ABI_TAG : & str = "graalpy230_310_native" ;
15+
16+ fn graalpy_version_for_python_version ( major : usize , minor : usize ) -> Option < ( usize , usize ) > {
17+ match ( major, minor) {
18+ ( 3 , 10 ) => Some ( ( 24 , 0 ) ) ,
19+ ( 3 , 11 ) => Some ( ( 24 , 2 ) ) ,
20+ // Since 25.0, GraalPy should only change the major release number for feature releases.
21+ // Additionally, it promises that only the autumn (oddly-numbered) releases are
22+ // allowed to break ABI compatibility, so only those can change the Python version.
23+ // The even-numbered releases will report the ABI version of the previous release.
24+ // So assuming that GraalPy doesn't fall terribly behind on updating Python version,
25+ // the version used in the ABI should follow this formula
26+ ( 3 , 12 ..) => Some ( ( 25 + ( minor - 12 ) * 2 , 0 ) ) ,
27+ ( _, _) => None ,
28+ }
29+ }
1630
1731/// Some of the sysconfigdata of Python interpreter we care about
1832#[ derive( Debug , Clone , Deserialize , Eq , PartialEq ) ]
@@ -92,6 +106,20 @@ impl InterpreterConfig {
92106 gil_disabled,
93107 } )
94108 }
109+ ( Os :: Linux , GraalPy ) => {
110+ let ( graalpy_major, graalpy_minor) =
111+ graalpy_version_for_python_version ( major, minor) ?;
112+ let ext_suffix = format ! ( ".graalpy{graalpy_major}{graalpy_minor}-{major}{minor}-native-{python_ext_arch}-linux.so" ) ;
113+ Some ( Self {
114+ major,
115+ minor,
116+ interpreter_kind : GraalPy ,
117+ abiflags : String :: new ( ) ,
118+ ext_suffix,
119+ pointer_width : Some ( target. pointer_width ( ) ) ,
120+ gil_disabled,
121+ } )
122+ }
95123 ( Os :: Macos , CPython ) => {
96124 let abiflags = if python_version < ( 3 , 8 ) {
97125 "m" . to_string ( )
@@ -122,6 +150,20 @@ impl InterpreterConfig {
122150 gil_disabled,
123151 } )
124152 }
153+ ( Os :: Macos , GraalPy ) => {
154+ let ( graalpy_major, graalpy_minor) =
155+ graalpy_version_for_python_version ( major, minor) ?;
156+ let ext_suffix = format ! ( ".graalpy{graalpy_major}{graalpy_minor}-{major}{minor}-native-{python_ext_arch}-darwin.so" ) ;
157+ Some ( Self {
158+ major,
159+ minor,
160+ interpreter_kind : GraalPy ,
161+ abiflags : String :: new ( ) ,
162+ ext_suffix,
163+ pointer_width : Some ( target. pointer_width ( ) ) ,
164+ gil_disabled,
165+ } )
166+ }
125167 ( Os :: Windows , CPython ) => {
126168 let abiflags = if python_version < ( 3 , 8 ) {
127169 "m" . to_string ( )
@@ -319,7 +361,11 @@ impl InterpreterConfig {
319361 }
320362 }
321363 InterpreterKind :: PyPy => abi_tag. unwrap_or_else ( || PYPY_ABI_TAG . to_string ( ) ) ,
322- InterpreterKind :: GraalPy => abi_tag. unwrap_or_else ( || GRAALPY_ABI_TAG . to_string ( ) ) ,
364+ InterpreterKind :: GraalPy => abi_tag. unwrap_or_else ( || {
365+ let ( graalpy_major, graalpy_minor) =
366+ graalpy_version_for_python_version ( major, minor) . unwrap_or ( ( 23 , 0 ) ) ;
367+ format ! ( "graalpy{graalpy_major}{graalpy_minor}_{major}{minor}_native" )
368+ } ) ,
323369 } ;
324370 let file_ext = if target. is_windows ( ) { "pyd" } else { "so" } ;
325371 let ext_suffix = if target. is_linux ( ) || target. is_macos ( ) || target. is_hurd ( ) {
0 commit comments