fix(bindings): improve python platform detection

(cherry picked from commit 99988b7081)
This commit is contained in:
ObserverOfTime 2025-05-22 08:44:03 +03:00 committed by Will Lillis
parent e920009d60
commit 3c0088f037
2 changed files with 8 additions and 4 deletions

View file

@ -624,10 +624,15 @@ pub fn generate_grammar_files(
allow_update,
|path| generate_file(path, SETUP_PY_TEMPLATE, language_name, &generate_opts),
|path| {
let contents = fs::read_to_string(path)?;
let mut contents = fs::read_to_string(path)?;
if !contents.contains("egg_info") || !contents.contains("Py_GIL_DISABLED") {
eprintln!("Replacing setup.py");
generate_file(path, SETUP_PY_TEMPLATE, language_name, &generate_opts)?;
} else {
contents = contents
.replace("path\nfrom platform import system", "name as os_name, path")
.replace("system() != \"Windows\"", "os_name != \"nt\"");
write_file(path, contents)?;
}
Ok(())
},