Last active
October 7, 2017 13:48
-
-
Save tusharpm/ac0eef89796ca9c67ca92fe6c6071f6b to your computer and use it in GitHub Desktop.
Cython raw string literal broken example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Cython.Compiler import Options | |
| Options.annotate = True | |
| Options.fast_fail = True | |
| from Cython.Build import cythonize | |
| cythonize(["main.pyx"], language='c++') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mypxd cimport ( | |
| myInt | |
| ) | |
| print(myInt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This one works. | |
| # cdef extern from ".\\util.h": | |
| # This one doesn't. | |
| cdef extern from r".\util.h": | |
| const unsigned myInt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const unsigned myInt = 32768; |
Author
The two commands are actually not equivalent because you are not enabling Py3 mode in the first. Shouldn't make a difference here, though...
Author
Nice catch. That was the problem.
Adding #cython: language_level=3 to the pxd file solved it.
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fails for the command:
python cythonize.py[where python is python.exe from python36 install directory]
But works for the equivalent command:
cython -a --cplus -3 --fast-fail main.pyx[where cython is cython.exe from python36 scripts directory]