trolldbois / ctypeslib

Generate python ctypes classes from C headers. Requires LLVM clang
http://trolldbois.blogspot.com/search?q=ctypeslib
MIT License
217 stars 59 forks source link

macOS quirks #131

Open joseph-long opened 7 months ago

joseph-long commented 7 months ago

I've gotten all the dependencies installed with mamba / conda packages, and successfully ran clang2py on my target library's header, but it required some finagling. I'm documenting the workarounds here in case they're useful:

To get stdlib headers, you must supply the path from xcrun --show-sdk-path to clang. So, --clang-args="-isysroot $(xcrun --show-sdk-path)".

To run nm without an error, you need to make a workaround wrapper as described in #125.

Putting it all together,

clang2py --clang-args="-v -isysroot $(xcrun --show-sdk-path)" \
    --nm ./fake_nm.py \
    -l ../_build/src/libxrif.dylib xrif.h

If the maintainer is interested, I could try to make a PR that applies these changes by default when running on macOS.

trolldbois commented 7 months ago

Sure, propose a PR, I'll push it