@@ -450,13 +450,31 @@ pub mod common {
450450
451451 let bindings = Builder :: default ( )
452452 . clang_arg (
453- subdir ( base_dir_path. as_ref ( ) . join ( HOST_DIRNAME ) . join ( "include" ) ) . and_then (
454- |p| {
453+ subdir ( base_dir_path. as_ref ( ) . join ( HOST_DIRNAME ) . join ( "include" ) )
454+ . and_then ( |p| {
455455 p. to_str ( )
456456 . map ( |s| format ! ( "-I{}" , s) )
457457 . ok_or_else ( || anyhow ! ( "Could not convert path to string" ) )
458- } ,
459- ) ?,
458+ } )
459+ . or_else ( |_| {
460+ // Fallback for Simics 7.28.0+ where Python headers are in separate package (1033)
461+ println ! ( "cargo:warning=Traditional Python include path not found, trying Simics Python package fallback" ) ;
462+ let parent_dir = base_dir_path. as_ref ( ) . parent ( ) . unwrap ( ) ;
463+ let python_include_path = parent_dir
464+ . join ( "simics-python-7.10.0" )
465+ . join ( HOST_DIRNAME )
466+ . join ( "include" ) ;
467+ if python_include_path. exists ( ) {
468+ subdir ( & python_include_path)
469+ . and_then ( |p| {
470+ p. to_str ( )
471+ . map ( |s| format ! ( "-I{}" , s) )
472+ . ok_or_else ( || anyhow ! ( "Could not convert path to string" ) )
473+ } )
474+ } else {
475+ bail ! ( "Python include directory not found at {}" , python_include_path. display( ) )
476+ }
477+ } ) ?,
460478 )
461479 . clang_arg ( format ! ( "-I{}" , & wrapper_include_path) )
462480 . clang_arg ( "-fretain-comments-from-system-headers" )
@@ -774,11 +792,26 @@ pub mod common {
774792
775793 let libvtutils = bin_dir. join ( "libvtutils.so" ) . canonicalize ( ) ?;
776794
777- let sys_lib_dir = base_dir_path
795+ let traditional_sys_lib_path = base_dir_path
778796 . join ( HOST_DIRNAME )
779797 . join ( "sys" )
780- . join ( "lib" )
781- . canonicalize ( ) ?;
798+ . join ( "lib" ) ;
799+ println ! ( "cargo:warning=Trying traditional libpython path: {}" , traditional_sys_lib_path. display( ) ) ;
800+
801+ let sys_lib_dir = traditional_sys_lib_path
802+ . canonicalize ( )
803+ . or_else ( |_| {
804+ // Fallback for Simics 7.28.0+ where libpython is in separate package (1033)
805+ println ! ( "cargo:warning=Traditional libpython path not found, trying Simics Python package fallback" ) ;
806+ let parent_dir = base_dir_path. parent ( ) . unwrap ( ) ;
807+ let fallback_path = parent_dir
808+ . join ( "simics-python-7.10.0" )
809+ . join ( HOST_DIRNAME )
810+ . join ( "sys" )
811+ . join ( "lib" ) ;
812+ println ! ( "cargo:warning=Trying fallback libpython path: {}" , fallback_path. display( ) ) ;
813+ fallback_path. canonicalize ( )
814+ } ) ?;
782815
783816 let libpython = sys_lib_dir. join (
784817 read_dir ( & sys_lib_dir) ?
0 commit comments