uday
uday

Reputation: 6723

cython compiles but no pyd files are generated

I tried to run a python code, say myfile.py (also tried to rename it as myfile.pyx) as follows:

import pyximport
pyximport.install(setup_args={"script_args":["--compiler=mingw32"]},      
    reload_support=True)

import myfile
myfile.mycode()

I am using PyCharm. The code seems to have run fine without any error and even gave me correct results on the Python Console within PyCharm.

However no pyd (or pxd) files were generated. How can I know if my code (myfile.mycode()) ran via Cython or via regular Python?

I am using Python 3.4, Cython 0.21.2.

Thanks

Upvotes: 2

Views: 2726

Answers (1)

Saullo G. P. Castro
Saullo G. P. Castro

Reputation: 58955

pyximport generates a temporary pyd file that is not in the working directory. You probably want to build a setup.py that looks something like:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension('myfile',
                         sources=['myfile.pyx'],
                         language='c++',
                        )]
setup(
name = 'myfile',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)

which you can compile using:

python setup.py build_ext -i clean

Upvotes: 2

Related Questions