Skip to content

Commit 990bd0c

Browse files
authored
Simplify pyo3 config file rewrite logic
1 parent e81d71c commit 990bd0c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/compile.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,8 @@ fn cargo_build_command(
443443
fs::create_dir_all(&maturin_target_dir)?;
444444
// We don't want to rewrite the file every time as that will make cargo
445445
// 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 {
446+
let existing_pyo3_config = fs::read_to_string(&config_file).unwrap_or_default()
447+
if pyo3_config != existing_pyo3_config {
454448
fs::write(&config_file, pyo3_config).with_context(|| {
455449
format!(
456450
"Failed to create pyo3 config file at '{}'",

0 commit comments

Comments
 (0)