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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
7d763702
Commit
7d763702
authored
Sep 08, 2016
by
Robert Bradshaw
Committed by
GitHub
Sep 08, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #510 from jdemeyer/conditional_dependencies
Support dependencies in conditional compilation
parents
6c3f2815
db2518bb
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 @
7d763702
...
@@ -358,10 +358,13 @@ def strip_string_literals(code, prefix='__Pyx_L'):
...
@@ -358,10 +358,13 @@ def strip_string_literals(code, prefix='__Pyx_L'):
return
""
.
join
(
new_code
),
literals
return
""
.
join
(
new_code
),
literals
dependency_regex
=
re
.
compile
(
r"(?:^from +([0-9a-zA-Z_.]+) +cimport)|"
# We need to allow spaces to allow for conditional compilation like
r"(?:^cimport +([0-9a-zA-Z_.]+(?: *, *[0-9a-zA-Z_.]+)*))|"
# IF ...:
r"(?:^cdef +extern +from +['\"]([^'\"]+)['\"])|"
# cimport ...
r"(?:^include +['\"]([^'\"]+)['\"])"
,
re
.
M
)
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
):
def
normalize_existing
(
base_path
,
rel_paths
):
...
...
tests/compile/conditional_dependencies.srctree
0 → 100644
View file @
7d763702
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