My project reply on a SO file which I will make it by cmake installing under my project folder.And it works files when I run python setup.py install
But I install it by pip, because pip will copy the project into a tmpfile,It will be removed after installed and the SO file also be removed. Hence, when I import my project, it fails for not finding the SO file.
Of course, I can install the SO file to /usr/local/lib, but I don't want to
Anyone has idea to solve it?
You need to make your shared library discoverable at run time. Same rules applies as for regular C++ executable.
There are several options here (list might be incomplete):
/usr/lib/)/etc/ld.so.conf.d/my_lib.confLD_LIBRARY_PATH before calling python interpreterLD_PRELOAD to run python interpreterRPATH attribute of pybind11 module. I personally use the latter option: it allows me to use virtualenv freely
You can also take a look at auditwheel if you have a wheel package.
auditwheel repair: copies these external shared libraries into the wheel itself, and automatically modifies the appropriate RPATH entries such that these libraries will be picked up at runtime. This accomplishes a similar result as if the libraries had been statically linked without requiring changes to the build system. Packagers are advised that bundling, like static linking, may implicate copyright concerns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With