PyO3 / maturin

Build and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages
https://maturin.rs
Apache License 2.0
3.93k stars 273 forks source link

`maturin build --target x86_64-pc-windows-gnu --zig` results in a broken module #922

Open ravenexp opened 2 years ago

ravenexp commented 2 years ago

Bug Description

Running the above command succeeds, but shown a warning:

⚠️  Warning: Couldn't find the symbol `PyInit_testmodule` in the native library. Python will fail to import this module. If you're using pyo3, check that `#[pymodule]` uses `testmodule` as module name

I've checked the extension module with objdump, and it indeed does not export any symbols.

Building the same extension without --zig results in a working module exporting PyInit_testmodule.

Your Python version (python -V)

Python 3.10.4

Your pip version (pip -V)

pip 21.0

What bindings you're using

pyo3

Does cargo build work?

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

Steps to Reproduce

  1. Build with maturin build --target x86_64-pc-windows-gnu --zig
  2. Build with maturin build --target x86_64-pc-windows-gnu
  3. The first command results in a broken module, the second command works.
messense commented 2 years ago

Might be a zig issue, try search in zig's issue tracker: https://github.com/ziglang/zig/issues