fix(cli): init --update should not update setup.py after replacing it (#5760)

Co-authored-by: Philipp <philipp.zander@tweag.io>
This commit is contained in:
Will Lillis 2026-07-17 20:03:40 -04:00
parent f9b9b39075
commit c02f32485a

View file

@ -976,22 +976,23 @@ pub fn generate_grammar_files(
if !contents.contains("build_ext") {
info!("Replacing setup.py");
generate_file(path, SETUP_PY_TEMPLATE, language_name, &generate_opts)?;
}
if !contents.contains(" and not get_config_var") {
info!("Updating Python free-threading support in setup.py");
contents = contents.replace(
r#"startswith("cp"):"#,
r#"startswith("cp") and not get_config_var("Py_GIL_DISABLED"):"#
);
write_file(path, &contents)?;
}
if !contents.contains("include(\"src/*.c\")") {
info!("Updating sdist file list in setup.py");
let contents = contents.replace(
"include(\"src/tree_sitter/*.h\")",
"include(\"src/tree_sitter/*.h\")\n self.filelist.include(\"src/*.c\")",
);
write_file(path, &contents)?;
} else {
if !contents.contains(" and not get_config_var") {
info!("Updating Python free-threading support in setup.py");
contents = contents.replace(
r#"startswith("cp"):"#,
r#"startswith("cp") and not get_config_var("Py_GIL_DISABLED"):"#
);
write_file(path, &contents)?;
}
if !contents.contains("include(\"src/*.c\")") {
info!("Updating sdist file list in setup.py");
let contents = contents.replace(
"include(\"src/tree_sitter/*.h\")",
"include(\"src/tree_sitter/*.h\")\n self.filelist.include(\"src/*.c\")",
);
write_file(path, &contents)?;
}
}
Ok(())