Commit f43a1f0d authored by Robert Bradshaw's avatar Robert Bradshaw

Tests for common include dir.

parent 270ba13a
...@@ -652,6 +652,9 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo ...@@ -652,6 +652,9 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
""" """
if 'include_path' not in options: if 'include_path' not in options:
options['include_path'] = ['.'] options['include_path'] = ['.']
if 'common_utility_include_dir' in options:
if not os.path.exists(options['common_utility_include_dir']):
os.makedirs(options['common_utility_include_dir'])
c_options = CompilationOptions(**options) c_options = CompilationOptions(**options)
cpp_options = CompilationOptions(**options); cpp_options.cplus = True cpp_options = CompilationOptions(**options); cpp_options.cplus = True
ctx = c_options.create_context() ctx = c_options.create_context()
...@@ -811,6 +814,9 @@ def cythonize_one(pyx_file, c_file, fingerprint, quiet, options=None, raise_on_f ...@@ -811,6 +814,9 @@ def cythonize_one(pyx_file, c_file, fingerprint, quiet, options=None, raise_on_f
except (EnvironmentError, PyrexError), e: except (EnvironmentError, PyrexError), e:
sys.stderr.write('%s\n' % e) sys.stderr.write('%s\n' % e)
any_failures = 1 any_failures = 1
# XXX
import traceback
traceback.print_exc()
except Exception: except Exception:
if raise_on_failure: if raise_on_failure:
raise raise
......
...@@ -1540,7 +1540,7 @@ class CCodeWriter(object): ...@@ -1540,7 +1540,7 @@ class CCodeWriter(object):
def put_or_include(self, code, name): def put_or_include(self, code, name):
include_dir = self.globalstate.common_utility_include_dir include_dir = self.globalstate.common_utility_include_dir
if include_dir and len(code) > 1042: if include_dir and len(code) > 1024:
include_file = "%s_%s.h" % ( include_file = "%s_%s.h" % (
name, hashlib.md5(code).hexdigest()) name, hashlib.md5(code).hexdigest())
path = os.path.join(include_dir, include_file) path = os.path.join(include_dir, include_file)
......
PYTHON setup.py build_ext --inplace
PYTHON -c "import runner"
# Verify some files were created.
ls common/AddTraceback_impl*.h common/RaiseException_impl_*.h
# Verify that they're used.
grep -c '#include "common/AddTraceback_impl_.*h"' a.c
grep -c '#include "common/AddTraceback_impl_.*h"' b.c
grep -c '#include "common/AddTraceback_impl_.*h"' c.c
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize("*.pyx", common_utility_include_dir='common', nthreads=2),
)
######## a.pyx ########
def generator(n):
for k in range(n):
yield k
assert list(generator(10)) == list(range(10))
######## b.pyx ########
def generator(n):
for k in range(n):
yield k
assert list(generator(10)) == list(range(10))
if __name__ == "__main__":
print "here", "b"
######## c.pyx ########
if __name__ == "__main__":
print "here", "c"
######## runner.py ########
import a, b, c
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