Commit 9f98dac8 authored by Robert Bradshaw's avatar Robert Bradshaw

Incorporate William Stein's cythonize() suggestions.

--HG--
extra : transplant_source : %B9%E5%B2%13%F4w%85_%9C%AF%40Mp%10%BC%D2%99%F2Z%F5
parent 700aaca9
...@@ -446,7 +446,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None): ...@@ -446,7 +446,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None):
return module_list return module_list
# This is the user-exposed entry point. # This is the user-exposed entry point.
def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, **options): def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, force=False, **options):
if 'include_path' not in options: if 'include_path' not in options:
options['include_path'] = ['.'] options['include_path'] = ['.']
c_options = CompilationOptions(**options) c_options = CompilationOptions(**options)
...@@ -482,7 +482,7 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, ** ...@@ -482,7 +482,7 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, **
else: else:
dep_timestamp, dep = deps.newest_dependency(source) dep_timestamp, dep = deps.newest_dependency(source)
priority = 2 - (dep in deps.immediate_dependencies(source)) priority = 2 - (dep in deps.immediate_dependencies(source))
if c_timestamp < dep_timestamp: if force or c_timestamp < dep_timestamp:
if not quiet: if not quiet:
if source == dep: if source == dep:
print("Compiling %s because it changed." % source) print("Compiling %s because it changed." % source)
...@@ -505,14 +505,16 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, ** ...@@ -505,14 +505,16 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, **
nthreads = 0 nthreads = 0
if not nthreads: if not nthreads:
for priority, pyx_file, c_file, options in to_compile: for priority, pyx_file, c_file, options in to_compile:
cythonize_one(pyx_file, c_file, options) cythonize_one(pyx_file, c_file, quiet, options)
return module_list return module_list
# TODO: Share context? Issue: pyx processing leaks into pxd module # TODO: Share context? Issue: pyx processing leaks into pxd module
def cythonize_one(pyx_file, c_file, options=None): def cythonize_one(pyx_file, c_file, quiet, options=None):
from Cython.Compiler.Main import compile, default_options from Cython.Compiler.Main import compile, default_options
from Cython.Compiler.Errors import CompileError, PyrexError from Cython.Compiler.Errors import CompileError, PyrexError
if not quiet:
print "Cythonizing %s" % pyx_file
if options is None: if options is None:
options = CompilationOptions(default_options) options = CompilationOptions(default_options)
options.output_file = c_file options.output_file = c_file
......
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