pybind / python_example

Example pybind11 module built with a Python-based build system
Other
501 stars 148 forks source link

module builds but fails to load with non-cmake library #67

Closed sarnold closed 4 years ago

sarnold commented 4 years ago

I have a (mostly) working build using an older/more conventional pybind11 setup.py but when I try to follow this example I get an undefined symbol error when loading the module, eg, to run tests, etc. Neither my setup.py nor the external library have anything to do with cmake, so it would be really helpful if you had an example of such an extension build using the Pybind11Extension shown in this example.

henryiii commented 4 years ago

Do you have an example with the new style attempt? This example already explicitly does not require or use CMake. You should just be able to drop most of the custom code and use Pybind11Extension.

henryiii commented 4 years ago

Are you linking to an external library? Guessing so based on your comment in setup.py. If so, you need to add it and (if building wheels) include it with auditwheel (Linux) or dealocate (macOS). cibuildwheel will do that for you on CI.

sarnold commented 4 years ago

Sorry, i didn't push the updated branch until just now: https://github.com/freepn/google-re2/tree/no-link

Also I just got it to build/test locally, so I'll go ahead and merge it into the PR branch. Thanks!

sarnold commented 4 years ago

So, after more test variations on github windows the closest I can get with msvc compiler is something gets built, but doesn't load/run from the wheel. Even then I had to add static lib/include paths to setup.py to make anything build; there must a better way I'm not seeing...

sarnold commented 4 years ago

I could not get this approach to work on the windows ci runner but it works fine on the unix-y OSs. I'm going to update the re2 python setup based on your cmake example instead.

sarnold commented 4 years ago

This is working now on Linux/Macos/Windows: https://github.com/freepn/google-re2 The key thing for non-linux platforms is cmake find_package and/or the toolchain file for the platform (eg, vcpkg).