Skip to content

Commit

Permalink
enable 'binding' directive by default when compiling .py files
Browse files Browse the repository at this point in the history
  • Loading branch information
scoder committed Aug 23, 2012
1 parent f5bfa12 commit 621dbe6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
22 changes: 17 additions & 5 deletions Cython/Compiler/Main.py
Expand Up @@ -385,13 +385,14 @@ def create_default_resultobj(compilation_source, options):
def run_pipeline(source, options, full_module_name=None, context=None):
import Pipeline

source_ext = os.path.splitext(source)[1]
options.configure_language_defaults(source_ext[1:]) # py/pyx
if context is None:
context = options.create_context()

# Set up source object
cwd = os.getcwd()
abs_path = os.path.abspath(source)
source_ext = os.path.splitext(source)[1]
full_module_name = full_module_name or context.extract_module_name(source, options)

if options.relative_path_in_code_position_comments:
Expand Down Expand Up @@ -471,10 +472,21 @@ def __init__(self, defaults = None, **kw):
defaults = defaults.__dict__
else:
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'])

options = dict(defaults)
options.update(kw)

directives = dict(options['compiler_directives']) # copy mutable field
options['compiler_directives'] = directives
if 'language_level' in directives and 'language_level' not in kw:
options['language_level'] = int(directives['language_level'])

self.__dict__.update(options)

def configure_language_defaults(self, source_extension):
if source_extension == 'py':
if self.compiler_directives.get('binding') is None:
self.compiler_directives['binding'] = True

def create_context(self):
return Context(self.include_path, self.compiler_directives,
Expand Down
3 changes: 2 additions & 1 deletion Cython/Compiler/Options.py
Expand Up @@ -124,7 +124,7 @@
'test_fail_if_path_exists' : [],

# experimental, subject to change
'binding': False,
'binding': None,
'experimental_cpp_class_def': False
}

Expand All @@ -140,6 +140,7 @@
'final' : bool, # final cdef classes and methods
'internal' : bool, # cdef class visibility in the module dict
'infer_types' : bool, # values can be True/None/False
'binding' : bool,
'cfunc' : None, # decorators do not take directive value
'ccall' : None,
'cclass' : None,
Expand Down

0 comments on commit 621dbe6

Please sign in to comment.