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
bc01fbfd
Commit
bc01fbfd
authored
Dec 05, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
propagate build options
parent
bcb9ab3b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+12
-7
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+5
-2
No files found.
Cython/Build/Dependencies.py
View file @
bc01fbfd
...
@@ -10,6 +10,7 @@ except NameError:
...
@@ -10,6 +10,7 @@ except NameError:
from
distutils.extension
import
Extension
from
distutils.extension
import
Extension
from
Cython
import
Utils
from
Cython
import
Utils
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
,
default_options
# Unfortunately, Python 2.3 doesn't support decorators.
# Unfortunately, Python 2.3 doesn't support decorators.
def
cached_method
(
f
):
def
cached_method
(
f
):
...
@@ -377,12 +378,11 @@ def create_dependency_tree(ctx=None):
...
@@ -377,12 +378,11 @@ def create_dependency_tree(ctx=None):
global
_dep_tree
global
_dep_tree
if
_dep_tree
is
None
:
if
_dep_tree
is
None
:
if
ctx
is
None
:
if
ctx
is
None
:
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
ctx
=
Context
([
"."
],
CompilationOptions
(
default_options
))
ctx
=
Context
([
"."
],
CompilationOptions
(
default_options
))
_dep_tree
=
DependencyTree
(
ctx
)
_dep_tree
=
DependencyTree
(
ctx
)
return
_dep_tree
return
_dep_tree
# T
ODO: This may be useful for advanced users.
# T
his may be useful for advanced users?
def
create_extension_list
(
patterns
,
ctx
=
None
,
aliases
=
None
):
def
create_extension_list
(
patterns
,
ctx
=
None
,
aliases
=
None
):
seen
=
set
()
seen
=
set
()
deps
=
create_dependency_tree
(
ctx
)
deps
=
create_dependency_tree
(
ctx
)
...
@@ -423,7 +423,10 @@ def create_extension_list(patterns, ctx=None, aliases=None):
...
@@ -423,7 +423,10 @@ def create_extension_list(patterns, ctx=None, aliases=None):
return
module_list
return
module_list
# This is the user-exposed entry point.
# This is the user-exposed entry point.
def
cythonize
(
module_list
,
ctx
=
None
,
nthreads
=
0
,
aliases
=
None
):
def
cythonize
(
module_list
,
nthreads
=
0
,
aliases
=
None
,
**
options
):
c_options
=
CompilationOptions
(
options
)
cpp_options
=
CompilationOptions
(
options
);
cpp_options
.
cplus
=
True
ctx
=
options
.
create_context
()
module_list
=
create_extension_list
(
module_list
,
ctx
=
ctx
,
aliases
=
aliases
)
module_list
=
create_extension_list
(
module_list
,
ctx
=
ctx
,
aliases
=
aliases
)
deps
=
create_dependency_tree
(
ctx
)
deps
=
create_dependency_tree
(
ctx
)
to_compile
=
[]
to_compile
=
[]
...
@@ -434,8 +437,10 @@ def cythonize(module_list, ctx=None, nthreads=0, aliases=None):
...
@@ -434,8 +437,10 @@ def cythonize(module_list, ctx=None, nthreads=0, aliases=None):
if
ext
in
(
'.pyx'
,
'.py'
):
if
ext
in
(
'.pyx'
,
'.py'
):
if
m
.
language
==
'c++'
:
if
m
.
language
==
'c++'
:
c_file
=
base
+
'.cpp'
c_file
=
base
+
'.cpp'
options
=
cpp_options
else
:
else
:
c_file
=
base
+
'.c'
c_file
=
base
+
'.c'
options
=
c_options
if
os
.
path
.
exists
(
c_file
):
if
os
.
path
.
exists
(
c_file
):
c_timestamp
=
os
.
path
.
getmtime
(
c_file
)
c_timestamp
=
os
.
path
.
getmtime
(
c_file
)
else
:
else
:
...
@@ -450,7 +455,7 @@ def cythonize(module_list, ctx=None, nthreads=0, aliases=None):
...
@@ -450,7 +455,7 @@ def cythonize(module_list, ctx=None, nthreads=0, aliases=None):
priority
=
2
-
(
dep
in
deps
.
immediate_dependencies
(
source
))
priority
=
2
-
(
dep
in
deps
.
immediate_dependencies
(
source
))
if
c_timestamp
<
dep_timestamp
:
if
c_timestamp
<
dep_timestamp
:
print
(
"Compiling %s because it depends on %s"
%
(
source
,
dep
))
print
(
"Compiling %s because it depends on %s"
%
(
source
,
dep
))
to_compile
.
append
((
priority
,
source
,
c_file
))
to_compile
.
append
((
priority
,
source
,
c_file
,
options
))
new_sources
.
append
(
c_file
)
new_sources
.
append
(
c_file
)
else
:
else
:
new_sources
.
append
(
source
)
new_sources
.
append
(
source
)
...
@@ -466,13 +471,13 @@ def cythonize(module_list, ctx=None, nthreads=0, aliases=None):
...
@@ -466,13 +471,13 @@ def cythonize(module_list, ctx=None, nthreads=0, aliases=None):
print
(
"multiprocessing required for parallel cythonization"
)
print
(
"multiprocessing required for parallel cythonization"
)
nthreads
=
0
nthreads
=
0
if
not
nthreads
:
if
not
nthreads
:
for
priority
,
pyx_file
,
c_file
in
to_compile
:
for
priority
,
pyx_file
,
c_file
,
options
in
to_compile
:
cythonize_one
(
pyx_file
,
c_file
)
cythonize_one
(
pyx_file
,
c_file
,
options
)
return
module_list
return
module_list
# TODO: Share context? Issue: pyx processing leaks into pxd module
# TODO: Share context? Issue: pyx processing leaks into pxd module
def
cythonize_one
(
pyx_file
,
c_file
,
options
=
None
):
def
cythonize_one
(
pyx_file
,
c_file
,
options
=
None
):
from
Cython.Compiler.Main
import
compile
,
CompilationOptions
,
default_options
from
Cython.Compiler.Main
import
compile
,
default_options
from
Cython.Compiler.Errors
import
CompileError
,
PyrexError
from
Cython.Compiler.Errors
import
CompileError
,
PyrexError
if
options
is
None
:
if
options
is
None
:
...
...
Cython/Compiler/Main.py
View file @
bc01fbfd
...
@@ -564,8 +564,7 @@ def create_default_resultobj(compilation_source, options):
...
@@ -564,8 +564,7 @@ def create_default_resultobj(compilation_source, options):
def
run_pipeline
(
source
,
options
,
full_module_name
=
None
):
def
run_pipeline
(
source
,
options
,
full_module_name
=
None
):
# Set up context
# Set up context
context
=
Context
(
options
.
include_path
,
options
.
compiler_directives
,
context
=
optons
.
create_context
()
options
.
cplus
,
options
.
language_level
)
# Set up source object
# Set up source object
cwd
=
os
.
getcwd
()
cwd
=
os
.
getcwd
()
...
@@ -636,6 +635,10 @@ class CompilationOptions(object):
...
@@ -636,6 +635,10 @@ class CompilationOptions(object):
self
.
__dict__
.
update
(
defaults
)
self
.
__dict__
.
update
(
defaults
)
self
.
__dict__
.
update
(
kw
)
self
.
__dict__
.
update
(
kw
)
def
create_context
(
self
):
return
Context
(
self
.
include_path
,
self
.
compiler_directives
,
self
.
cplus
,
self
.
language_level
)
class
CompilationResult
(
object
):
class
CompilationResult
(
object
):
"""
"""
...
...
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