File tree 1 file changed +17
-6
lines changed
1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -441,12 +441,23 @@ fn cargo_build_command(
441
441
target_triple, interpreter. major, interpreter. minor
442
442
) ) ;
443
443
fs:: create_dir_all ( & maturin_target_dir) ?;
444
- fs:: write ( & config_file, pyo3_config) . with_context ( || {
445
- format ! (
446
- "Failed to create pyo3 config file at '{}'" ,
447
- config_file. display( )
448
- )
449
- } ) ?;
444
+ // We don't want to rewrite the file every time as that will make cargo
445
+ // trigger a rebuild of the project every time
446
+ let rewrite = if config_file. exists ( ) {
447
+ std:: fs:: read_to_string ( & config_file)
448
+ . map ( |previous| previous != pyo3_config)
449
+ . unwrap_or ( false )
450
+ } else {
451
+ true
452
+ } ;
453
+ if rewrite {
454
+ fs:: write ( & config_file, pyo3_config) . with_context ( || {
455
+ format ! (
456
+ "Failed to create pyo3 config file at '{}'" ,
457
+ config_file. display( )
458
+ )
459
+ } ) ?;
460
+ }
450
461
let abs_config_file = config_file. normalize ( ) ?. into_path_buf ( ) ;
451
462
build_command. env ( "PYO3_CONFIG_FILE" , abs_config_file) ;
452
463
}
You can’t perform that action at this time.
0 commit comments