WildCrustacean
WildCrustacean

Reputation: 5966

How to help Python locate shared object files in CFFI package

I am working on making a python wrapper for some existing code using CFFI, but I'm getting stuck with packaging and distribution for Linux.

I've loosely followed the example here: https://github.com/wolever/python-cffi-example

And I've read this question as well: How to use shared dynamic libraries with python-cffi (in linux)?

I can get the python packager to install the .so file into the site-packages folder, but I can't get Python to locate it there (results in an ImportError: cannot open shared object file).

If I manually copy the .so file to /usr/lib or /usr/local/lib everything works fine, but I can't get the python package to copy files there (absolute paths don't work in a wheel) and that doesn't seem like the right answer anyway.

I also looked at modifying LD_LIBRARY_PATH in my python startup code, but that doesn't take effect for the current process only for new ones so that doesn't work either.

How can I distribute a .so file with a python package in a way that it can be located when the package is imported?

Upvotes: 0

Views: 361

Answers (0)

Related Questions