I am working with compiler directives for Cython (http://docs.cython.org/en/latest/src/reference/compilation.html#globally).
$ cat temp.pyx
# cython: language_level=3
print("abc", "def", sep=" ,") # invalid in python 2
Compiling:
$ cythonize -i world_dep.pyx
Error compiling Cython file:
------------------------------------------------------------
...
# cython: language_level=3
print("abc", "def", sep=" ,") ^
------------------------------------------------------------
temp.pyx:4:23: Expected ')', found '='
So language_level directive is not getting respected. Thus, cythonize ends up using Python 2 semantics and the error is thrown as the print statement above is invalid in Python 2.
However, including any Python statement makes this work:
$ cat temp.pyx
# cython: language_level=3
import os
print("abc", "def", sep=" ,")
Compiling and executing:
$ cythonize -i temp.pyx; python -c "import temp"
abc, def
Any idea how the import statement is making the language_level to be respected?
I have raised this same issue on the Cython GitHub repository as well?