Commit c5be029b authored by Stefan Behnel's avatar Stefan Behnel

fix for passing language_level externally as compiler directive

parent f58ddd33
......@@ -473,6 +473,8 @@ class CompilationOptions(object):
defaults = default_options
self.__dict__.update(defaults)
self.__dict__.update(kw)
if 'language_level' not in kw and 'language_level' in self.compiler_directives:
self.language_level = int(self.compiler_directives['language_level'])
def create_context(self):
return Context(self.include_path, self.compiler_directives,
......
......@@ -183,6 +183,7 @@ VER_DEP_MODULES = {
'run.initial_file_path', # relative import
]),
(2,6) : (operator.lt, lambda x: x in ['run.print_function',
'run.language_level', # print function
'run.cython3',
'run.property_decorator_T593', # prop.setter etc.
'run.generators_py', # generators, with statement
......
PYTHON setup.py build_ext --inplace
PYTHON -c "import directive2; import directive3"
PYTHON -c "import infile2; import infile3"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = (cythonize("infile*.py") +
cythonize("directive2.py", compiler_directives={'language_level': 2}) +
cythonize("directive3.py", compiler_directives={'language_level': 3})
)
)
######## directive3.py ########
import sys
print("SUCCESS", file=sys.stdout)
######## directive2.py ########
print "SUCCESS"
######## infile3.py ########
# cython: language_level=3
import sys
print("SUCCESS", file=sys.stdout)
######## infile2.py ########
# cython: language_level=2
print "SUCCESS"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment