You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The preferred approach to building an extension module for python is to compile it with distutils, which comes with all recent versions of python (Distutils Docs).
... A configuration file (conventionally called: setup.py) describes the extension (and related python modules). The distutils will then generate all the right compiler directives to build it for you.
There's an example setup.py which imports setup and Extension from distutils.core, and then configures an Extension object pointing at example_wrap.c and example.c - is example_wrap.c generated by SWIG? Ah, yes, the next paragraph notes "example_wrap.c, generated by swig, and example.c, your original c source." I guess for us it would be ... all (??) of the source files, plus the generated _wrap.cxx.
It then calls setup(), passing in the module defined in the Extension object, and some string metadata.
The distutils page now says that it's deprecated, and points to setuptools instead, which looks like quite a similar (identical?) API.
That has a library and a "main" which uses the library (I think in our case we only have the "main" library?), a .i file which just %includes the "main" .h file, and then a setup.py.in which is configure_filed in the CMakeLists.txt file to point to the correct filenames to pass to the filenames argument for setuptools' install function.
Their setup.py seems to only do the install part, rather than actually building the library; the building part looks quite similar to what we do. And the install part just copies the files??
Right now, we need to do an extra step to tell ld.so where to find the .so objects when loading the Python library.
Some cursory research suggests that it might be possible to install the Python library such that this step is no longer necessary.
The text was updated successfully, but these errors were encountered: