Commit 7d763702 authored by Robert Bradshaw's avatar Robert Bradshaw Committed by GitHub

Merge pull request #510 from jdemeyer/conditional_dependencies

Support dependencies in conditional compilation
parents 6c3f2815 db2518bb
......@@ -358,10 +358,13 @@ def strip_string_literals(code, prefix='__Pyx_L'):
return "".join(new_code), literals
dependency_regex = re.compile(r"(?:^from +([0-9a-zA-Z_.]+) +cimport)|"
r"(?:^cimport +([0-9a-zA-Z_.]+(?: *, *[0-9a-zA-Z_.]+)*))|"
r"(?:^cdef +extern +from +['\"]([^'\"]+)['\"])|"
r"(?:^include +['\"]([^'\"]+)['\"])", re.M)
# We need to allow spaces to allow for conditional compilation like
# IF ...:
# cimport ...
dependency_regex = re.compile(r"(?:^\s*from +([0-9a-zA-Z_.]+) +cimport)|"
r"(?:^\s*cimport +([0-9a-zA-Z_.]+(?: *, *[0-9a-zA-Z_.]+)*))|"
r"(?:^\s*cdef +extern +from +['\"]([^'\"]+)['\"])|"
r"(?:^\s*include +['\"]([^'\"]+)['\"])", re.M)
def normalize_existing(base_path, rel_paths):
......
PYTHON setup.py build_ext --inplace
######## setup.py ########
from Cython.Build import cythonize
ext_modules = cythonize("foo.pyx")
assert set(ext_modules[0].depends) == set(["a.h", "b.h", "c.h", "d.h"])
######## foo.pyx ########
IF 1:
cimport a
from b cimport something
include "c.pxi"
cdef extern from "d.h":
pass
######## a.pxd ########
cdef extern from "a.h":
pass
######## b.pxd ########
cdef extern from "b.h":
cdef void something()
######## c.pxi ########
cdef extern from "c.h":
pass
######## a.h ########
/* empty */
######## b.h ########
/* empty */
######## c.h ########
/* empty */
######## d.h ########
/* empty */
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