diff --git a/crates/cli/src/init.rs b/crates/cli/src/init.rs index 673c3771b..89a378a4d 100644 --- a/crates/cli/src/init.rs +++ b/crates/cli/src/init.rs @@ -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(())