Skip to content

Commit

Permalink
Merge pull request #531 from messense/warn-missing-py-init-windows
Browse files Browse the repository at this point in the history
Implement missing `PyInit_<module_name>` warning for Windows DLL
  • Loading branch information
messense authored May 7, 2021
2 parents 4dde4b6 + f083547 commit caf0ff9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn compile_target(
/// That function is the python's entrypoint for loading native extensions, i.e. python will fail
/// to import the module with error if it's missing or named incorrectly
///
/// Currently the check is only run on linux and macOS
/// Currently the check is only run on linux, macOS and Windows
pub fn warn_missing_py_init(artifact: &Path, module_name: &str) -> Result<()> {
let py_init = format!("PyInit_{}", module_name);
let mut fd = File::open(&artifact)?;
Expand Down Expand Up @@ -326,8 +326,18 @@ pub fn warn_missing_py_init(artifact: &Path, module_name: &str) -> Result<()> {
}
}
}
goblin::Object::PE(pe) => {
for sym in &pe.exports {
if let Some(sym_name) = sym.name {
if py_init == sym_name {
found = true;
break;
}
}
}
}
_ => {
// Currently, only linux and macOS are implemented
// Currently, only linux, macOS and Windows are implemented
found = true
}
}
Expand Down

0 comments on commit caf0ff9

Please sign in to comment.