I wrote a Python 3 extension module in C but cannot seem to get Python to import it.
Is there any way to let Python print out which shared libraries (.so on Linux) it tries to load and why it fails?
Sadly all the docs I read don't really help since none describes the native import procedure in a concise way.
What I tried is:
ctypes.CDLL("libmydep1.so")
ctypes.CDLL("libmydep2.so")
try:
import my_main
print("Load python")
except:
ctypes.CDLL("libmylib.so")
print("Load shared object")
Which always prints Load shared object
.
libmylib.so
contains the python entry point but loading it as Python 3 extension does not seem to work, although loading as a shared library does.
EDIT:
Python does not honor linux conventions. So for a lib you do not name it libmylib.so
but mylib.so
.
Even worse, it only loads my_main
, when the so is named my_main.so
. So annoying.