I have implemented a ctypes wrapper called api.c, and I have the structure:
lib/api.c
foo.py
setup.py
Compiling api.c manually and calling ctypes.CDLL(path+'lib/api.so') inside foo.py works, where path is the absolute pathname.
Now, I want distribute it with setup.py:
setup(name='foo',
ext_modules=[Extension('lib.api', ['lib/api.c'])]
)
Installing with python setup.py develop -u --user works, too, because api.so appears in lib/.
With python setup.py install --user the code is compiled, too, but api.so appears in some build/bdist.linux-x86_64/egg/lib folder.
Therefore importing the module results in
OSError: /.../lib/api.so: cannot open shared object file: No such file or directory
So how can I distribute it with install and what should be the value of path?
related issues: How to include a shared C library in a Python package