use std::path::{Path, PathBuf};
fn main() {
let lib_path: PathBuf = std::env::args()
.nth(1)
.expect("Usage: gen_stubs <path_to_compiled_extension>")
.into();
let module = pyo3_introspection::introspect_cdylib(&lib_path, "sassy")
.unwrap_or_else(|e| panic!("Failed to introspect {}: {e}", lib_path.display()));
let stubs = pyo3_introspection::module_stub_files(&module);
for (rel_path, content) in &stubs {
let output = Path::new("python/sassy").join(rel_path);
if let Some(parent) = output.parent() {
std::fs::create_dir_all(parent)
.unwrap_or_else(|e| panic!("Failed to create {}: {e}", parent.display()));
}
std::fs::write(&output, content)
.unwrap_or_else(|e| panic!("Failed to write {}: {e}", output.display()));
eprintln!("Wrote {}", output.display());
}
}