@@ -390,12 +390,16 @@ fn find_sysconfigdata(cross: &CrossCompileConfig) -> Result<PathBuf> {
390
390
cross. lib_dir. display( )
391
391
) ;
392
392
} else if sysconfig_paths. len ( ) > 1 {
393
- bail ! (
394
- "Detected multiple possible python versions, please set the PYO3_PYTHON_VERSION \
395
- variable to the wanted version on your system or set the _PYTHON_SYSCONFIGDATA_NAME \
396
- variable to the wanted sysconfigdata file name\n sysconfigdata paths = {:?}",
397
- sysconfig_paths
398
- )
393
+ let mut error_msg = String :: from (
394
+ "Detected multiple possible Python versions. Please set either the \
395
+ PYO3_CROSS_PYTHON_VERSION variable to the wanted version or the \
396
+ _PYTHON_SYSCONFIGDATA_NAME variable to the wanted sysconfigdata file name.\n \n \
397
+ sysconfigdata files found:",
398
+ ) ;
399
+ for path in sysconfig_paths {
400
+ error_msg += & format ! ( "\n \t {}" , path. display( ) ) ;
401
+ }
402
+ bail ! ( "{}" , error_msg) ;
399
403
}
400
404
401
405
Ok ( sysconfig_paths. remove ( 0 ) )
@@ -846,7 +850,7 @@ fn abi3_without_interpreter() -> Result<()> {
846
850
Ok ( ( ) )
847
851
}
848
852
849
- fn main ( ) -> Result < ( ) > {
853
+ fn main_impl ( ) -> Result < ( ) > {
850
854
// If PYO3_NO_PYTHON is set with abi3, we can build PyO3 without calling Python.
851
855
// We only check for the abi3-py3{ABI3_MAX_MINOR} because lower versions depend on it.
852
856
if env:: var_os ( "PYO3_NO_PYTHON" ) . is_some ( )
@@ -914,3 +918,11 @@ fn main() -> Result<()> {
914
918
915
919
Ok ( ( ) )
916
920
}
921
+
922
+ fn main ( ) {
923
+ // Print out error messages using display, to get nicer formatting.
924
+ let _ = main_impl ( ) . map_err ( |e| {
925
+ eprintln ! ( "Error: {}" , e) ;
926
+ std:: process:: exit ( 1 )
927
+ } ) ;
928
+ }
0 commit comments