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
Boxiang Sun
cython
Commits
f43a1f0d
Commit
f43a1f0d
authored
Aug 09, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for common include dir.
parent
270ba13a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
1 deletion
+56
-1
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+6
-0
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-1
tests/build/common_include_dir.srctree
tests/build/common_include_dir.srctree
+49
-0
No files found.
Cython/Build/Dependencies.py
View file @
f43a1f0d
...
...
@@ -652,6 +652,9 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
"""
if
'include_path'
not
in
options
:
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
)
cpp_options
=
CompilationOptions
(
**
options
);
cpp_options
.
cplus
=
True
ctx
=
c_options
.
create_context
()
...
...
@@ -811,6 +814,9 @@ def cythonize_one(pyx_file, c_file, fingerprint, quiet, options=None, raise_on_f
except
(
EnvironmentError
,
PyrexError
),
e
:
sys
.
stderr
.
write
(
'%s
\
n
'
%
e
)
any_failures
=
1
# XXX
import
traceback
traceback
.
print_exc
()
except
Exception
:
if
raise_on_failure
:
raise
...
...
Cython/Compiler/Code.py
View file @
f43a1f0d
...
...
@@ -1540,7 +1540,7 @@ class CCodeWriter(object):
def
put_or_include
(
self
,
code
,
name
):
include_dir
=
self
.
globalstate
.
common_utility_include_dir
if
include_dir
and
len
(
code
)
>
10
42
:
if
include_dir
and
len
(
code
)
>
10
24
:
include_file
=
"%s_%s.h"
%
(
name
,
hashlib
.
md5
(
code
).
hexdigest
())
path
=
os
.
path
.
join
(
include_dir
,
include_file
)
...
...
tests/build/common_include_dir.srctree
0 → 100644
View file @
f43a1f0d
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
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