You should use a .pyxbld
file, see for example this question.
For a file named foo.pyx
, you would make a foo.pyxbld
file. The following would give extra optimization args:
def make_ext(modname, pyxfilename):
from distutils.extension import Extension
return Extension(name=modname,
sources=[pyxfilename],
extra_compile_args=['-O3', '-march=native'])
I think it might be possible to pass in extra setup options to pyximport.install
if you jump through enough hoops (messing around with distribute
) to get the setup_args in the form it likes, however in the pyximport
module documentation it recommends using a .pyxbld
file, and in the test code for pyximport
only that method is tested, so if there is another way it should be considered unstable/untested and .pyxbld
should be considered the proper way of doing this.