Hello all,
I have a question about an exernal module I'm writing. I'm following the official tutorial at this page: https://docs.python.org/3/extending/extending.html
The question is simple. The tutorial says that I have to use PyMODINIT_FUNC to define a "startup" function that registers the module. Compiling the skeleton module with a basic setup.py works perfectly fine.
When I add the flag "-fvisibility=hidden" (see https://gcc.gnu.org/wiki/Visibility) to the compilation flags the PyMODINIT_FUNC function disappears, so the external module can't be imported anymore and this is the error:
Digging into Python C headers, I found the PyMODINIT_FUNC definition in /usr/include/python3.6/pyport.h; changing the definition from:
Now I'm aware this is a hack, but I'm wondering which is the right way to have visibility set to hidden and export correctly the module init function
I have a question about an exernal module I'm writing. I'm following the official tutorial at this page: https://docs.python.org/3/extending/extending.html
The question is simple. The tutorial says that I have to use PyMODINIT_FUNC to define a "startup" function that registers the module. Compiling the skeleton module with a basic setup.py works perfectly fine.
When I add the flag "-fvisibility=hidden" (see https://gcc.gnu.org/wiki/Visibility) to the compilation flags the PyMODINIT_FUNC function disappears, so the external module can't be imported anymore and this is the error:
Quote:ImportError: dynamic module does not define module export function (PyInit_pyopenvg)
Digging into Python C headers, I found the PyMODINIT_FUNC definition in /usr/include/python3.6/pyport.h; changing the definition from:
define PyMODINIT_FUNC extern "C" PyObject*to
define PyMODINIT_FUNC extern "C" __attribute__ ((visibility("default"))) PyObject*the module imports and works fine.
Now I'm aware this is a hack, but I'm wondering which is the right way to have visibility set to hidden and export correctly the module init function