I am trying to compile a simple cython module using the following setup.py:
from distutils.core import setup from Cython.Build import cythonize setup( ext_modules=cythonize("verifier_c.pyx"), ) I have the following folder structure:
. c_ext/ __init__.py verifier_c.pyx setup.py If I run the following:
python setup.py build_ext --inplace I get an extra c_ext subfolder like this:
. c_ext/ build/ ... c_ext/ verifier_c.so __init__.py verifier_c.pyx setup.py But if I remove the __init__.py file, I get the verifier_c.so file in the same folder as verifier_c.pyx.
I did not find where this behavior is documented, but I would like to keep verifier_c.so in the same folder as verifier_c.pyx but without having to delete __init__.py each time I run setup.py. How can I achieve that?
setup.pyis in the wrong folder. Move it up one level and change the argument ofcythonize()accordingly. Then the.sofile should show up in the already existingc_ext/folder (which is a package if there is a__init__.pyfile present.setup.pyand.pyxfile in the same folder and generate the.soin this folder? I would like to totally separate thecpart from the reste of my app (and thus not put thesetup.pyin the base app).setup.pyin that spot. It's part of the package the way you organized it. There is ac_ext.setupmodule this way which doesn't make sense.