I'm new to Cython, but got it working by following this basic guide from the official docs:
All it says is: "Cython has a way to visualise where interaction with Python objects and Python’s C-API is taking place. For this, pass the annotate=True parameter to cythonize(). It produces a HTML file."
I'm very surprised that I couldn't just Google this one or that no one on stackoverflow has asked this. But I can't figure out how to get it to work. It doesn't show specifically what it wants. So I tried the most obvious syntax (in Setup.py):
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("gpcython.pyx", annotate=True)
)
While this does not throw an error, I do not see any HTML being generated either.
I am on windows using the latest version of Python 3.7 with Cython 0.29.12.
https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html
To make your Python into Cython, first you need to create a file with the . pyx extension rather than the . py extension. Inside this file, you can start by writing regular Python code (note that there are some limitations in the Python code accepted by Cython, as clarified in the Cython docs).
Here is what I finally used that now seems to work:
from distutils.core import setup
from Cython.Build import cythonize
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
setup(
ext_modules = cythonize("gpcython.pyx", annotate=True)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With