This topic is basically dependent on the linking model that you choose if you are to choose the shared-library approach. I would recommend using Python distutils
and if you are going for embedded Python, and if you like GNU or autotools, this section gives an example you can use.
When compiling a native Python module, we can use distutils
and cythonize
inside our Setup.py
build. It's the preferred way in Python to use Cython as part of the build:
from distutils.core import setup from Cython.Build import cythonize setup( ext_modules = cythonize("sourcecode.pyx") )
This build file will support whichever version of Python you invoke the script with. When you run the build, your output will be of the same name of the input source code as a shared module in this case sourcecode.so
.