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
bcb9ab3b
Commit
bcb9ab3b
authored
Dec 05, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cython build cleanup.
parent
7637fcfc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+6
-6
Cython/Build/Inline.py
Cython/Build/Inline.py
+4
-7
No files found.
Cython/Build/Dependencies.py
View file @
bcb9ab3b
...
...
@@ -378,12 +378,11 @@ def create_dependency_tree(ctx=None):
if
_dep_tree
is
None
:
if
ctx
is
None
:
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
ctx
=
Context
([
"."
],
CompilationOptions
())
ctx
=
Context
([
"."
],
CompilationOptions
(
default_options
))
_dep_tree
=
DependencyTree
(
ctx
)
return
_dep_tree
# TODO: Take common options.
# TODO: Symbolic names (e.g. for numpy.include_dirs()
# TODO: This may be useful for advanced users.
def
create_extension_list
(
patterns
,
ctx
=
None
,
aliases
=
None
):
seen
=
set
()
deps
=
create_dependency_tree
(
ctx
)
...
...
@@ -423,6 +422,7 @@ def create_extension_list(patterns, ctx=None, aliases=None):
seen
.
add
(
name
)
return
module_list
# This is the user-exposed entry point.
def
cythonize
(
module_list
,
ctx
=
None
,
nthreads
=
0
,
aliases
=
None
):
module_list
=
create_extension_list
(
module_list
,
ctx
=
ctx
,
aliases
=
aliases
)
deps
=
create_dependency_tree
(
ctx
)
...
...
@@ -456,21 +456,21 @@ def cythonize(module_list, ctx=None, nthreads=0, aliases=None):
new_sources
.
append
(
source
)
m
.
sources
=
new_sources
to_compile
.
sort
()
# TODO: invoke directly
if
nthreads
:
# Requires multiprocessing (or Python >= 2.6)
try
:
import
multiprocessing
pool
=
multiprocessing
.
Pool
(
nthreads
)
pool
.
map
(
cythonize_one_helper
,
to_compile
)
except
ImportError
:
print
(
"multiprocessing required for parallel cythonization"
)
nthreads
=
0
pool
=
multiprocessing
.
Pool
(
nthreads
)
pool
.
map
(
cythonize_one_helper
,
to_compile
)
if
not
nthreads
:
for
priority
,
pyx_file
,
c_file
in
to_compile
:
cythonize_one
(
pyx_file
,
c_file
)
return
module_list
# TODO: Share context? Issue: pyx processing leaks into pxd module
def
cythonize_one
(
pyx_file
,
c_file
,
options
=
None
):
from
Cython.Compiler.Main
import
compile
,
CompilationOptions
,
default_options
from
Cython.Compiler.Errors
import
CompileError
,
PyrexError
...
...
Cython/Build/Inline.py
View file @
bcb9ab3b
...
...
@@ -50,12 +50,13 @@ def unbound_symbols(code, context=None):
if
not
tree
.
scope
.
lookup
(
name
)
and
not
hasattr
(
__builtin__
,
name
):
unbound
.
append
(
name
)
return
unbound
def
get_type
(
arg
,
context
=
None
):
py_type
=
type
(
arg
)
if
py_type
in
[
list
,
tuple
,
dict
,
str
]:
return
py_type
.
__name__
elif
py_type
is
complex
:
return
'double complex'
elif
py_type
is
float
:
return
'double'
elif
py_type
is
bool
:
...
...
@@ -75,11 +76,10 @@ def get_type(arg, context=None):
return
'%s.%s'
%
(
base_type
.
__module__
,
base_type
.
__name__
)
return
'object'
# TODO: use locals/globals for unbound variables
def
cython_inline
(
code
,
types
=
'aggressive'
,
lib_dir
=
os
.
path
.
expanduser
(
'~/.cython/inline'
),
include_dirs
=
[
'.'
],
cython_
include_dirs
=
[
'.'
],
locals
=
None
,
globals
=
None
,
**
kwds
):
...
...
@@ -108,9 +108,6 @@ def cython_inline(code,
arg_sigs
=
tuple
([(
get_type
(
kwds
[
arg
],
ctx
),
arg
)
for
arg
in
arg_names
])
key
=
code
,
arg_sigs
,
sys
.
version_info
,
sys
.
executable
,
Cython
.
__version__
module_name
=
"_cython_inline_"
+
hashlib
.
md5
(
str
(
key
)).
hexdigest
()
# # TODO: Does this cover all the platforms?
# if (not os.path.exists(os.path.join(lib_dir, module_name + ".so")) and
# not os.path.exists(os.path.join(lib_dir, module_name + ".dll"))):
try
:
if
not
os
.
path
.
exists
(
lib_dir
):
os
.
makedirs
(
lib_dir
)
...
...
@@ -147,7 +144,7 @@ def __invoke(%(params)s):
include_dirs = c_include_dirs)
build_extension = build_ext(Distribution())
build_extension.finalize_options()
build_extension.extensions = cythonize([extension])
build_extension.extensions = cythonize([extension]
, ctx=ctx
)
build_extension.build_temp = os.path.dirname(pyx_file)
build_extension.build_lib = lib_dir
build_extension.run()
...
...
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