I am trying to get cython to work on a project.
What I do is the following:
Create a file called
make_cython.py
import distutils.core import Cython.Build distutils.core.setup(ext_modules = Cython.Build.cythonize("main.py")) distutils.core.setup(ext_modules = Cython.Build.cythonize("helper.py"))
Run
python3 make_cython.py build_ext --inplace
Run for both cythnoized files
gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -Ipython/anaconda3/include/python3.9 -o main2.so main.c gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -Ipython/anaconda3/include/python3.9 -o helper2.so helper.c
Change all import calls that call
main.py
andhelper.py
in my scripts toimport main2
andimport helper2
.
Now, I have two questions:
if
helper.py
andmain.py
themselves have import for other.py
files, do I need to cythonize them too, and then change the imports, and then cythonize the new file, or is it all done recursively?I get the error when trying to run files that use
main2.so
(import main2
) andhelper2.so
(import helper2
):ImportError: helper2.so: undefined symbol: Py_EnterRecursiveCall
what did I miss in the compilation?