python distutils : access to name of compiled extension

python distutils : access to name of compiled extension … here is a solution to the problem.

python distutils : access to name of compiled extension

I used distutils to compile a swig-based extension module:

Python setup.py build_ext makefile _my_module_ext.cpython-32m.so (from .c and . I file). The name seems to depend on the version of python used (in my case, it’s python 3.2).

How do I access the name of this shared object from the setup.py or even from the module of the installed package?

The reason I need this is that I have a separate, ctypes-based python file that wants to load this file using numpy.ctypeslib.load_library.

Solution

The suffix is available via sysconfig.get_config_var('SO'). Read more about ABI tagged shared libraries at PEP 3149

Related Problems and Solutions