.pyx file to .so file in Python

2020-10-19
#Python

The content of setup.py is:

from distutils.core import setup
from Cython.Build import cythonize
import numpy

setup(
    ext_modules = cythonize("add_num.pyx"),
    include_dirs=[numpy.get_include()]
)

add_num.pyx is the import file.

Perform the command:

python setup.py build_ext --inplace

The add_num.so file will be obtained.

3. Reference