Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
db2518bb
Commit
db2518bb
authored
Apr 13, 2016
by
Jeroen Demeyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support dependencies in conditional compilation
parent
a9e41d96
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
4 deletions
+48
-4
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+7
-4
tests/compile/conditional_dependencies.srctree
tests/compile/conditional_dependencies.srctree
+41
-0
No files found.
Cython/Build/Dependencies.py
View file @
db2518bb
...
...
@@ -357,10 +357,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*cimpo
rt +([0-9a-zA-Z_.]+(?: *, *[0-9a-zA-Z_.]+)*))|"
r"(?:^\
s*cde
f +extern +from +['\"]([^'\"]+)['\"])|"
r"(?:^\
s*i
nclude +['\"]([^'\"]+)['\"])"
,
re
.
M
)
def
normalize_existing
(
base_path
,
rel_paths
):
...
...
tests/compile/conditional_dependencies.srctree
0 → 100644
View file @
db2518bb
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 */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment