I am using python 3.53 cython 0.28.2 and Visual studio compiler 2017. The example was taken from:
http://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html#cython-hello-world
I am trying to compile a simple helloworld.pyx
print ('hello world')
using visualstudio 2017. I tried two setup.py files
1st setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("helloworld", ["helloworld.pyx"])]
)
2nd setup.py
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("helloworld.pyx")
)
both succeeded using
python setup.py build_ext --inplace,
and generated the following dll:
helloworld.cp35-win_amd64.pyd
But when I import the generated pyd file using:
import helloworld.cp35-win_amd64
I get
import helloworld.cp35-win_amd64
^
SyntaxError: invalid syntax
Renaming the pyd file to shorter name without - or _ did not work.
Any suggestions are appreciated.