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
5266d1f9
Commit
5266d1f9
authored
Sep 13, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Aliases for inline dependencies (e.g. numpy_include_dirs).
parent
8e18e1c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
23 deletions
+47
-23
Cython/Compiler/Dependencies.py
Cython/Compiler/Dependencies.py
+44
-21
tests/build/inline_distutils.srctree
tests/build/inline_distutils.srctree
+3
-2
No files found.
Cython/Compiler/Dependencies.py
View file @
5266d1f9
...
...
@@ -68,24 +68,25 @@ def line_iter(source):
class
DistutilsInfo
(
object
):
def
__init__
(
self
,
source
):
def
__init__
(
self
,
source
=
None
):
self
.
values
=
{}
for
line
in
line_iter
(
source
):
line
=
line
.
strip
()
if
line
!=
''
and
line
[
0
]
!=
'#'
:
break
line
=
line
[
1
:].
strip
()
if
line
[:
10
]
==
'distutils:'
:
line
=
line
[
10
:]
ix
=
line
.
index
(
'='
)
key
=
str
(
line
[:
ix
].
strip
())
value
=
line
[
ix
+
1
:].
strip
()
type
=
distutils_settings
[
key
]
if
type
in
(
list
,
transitive_list
):
value
=
parse_list
(
value
)
if
key
==
'define_macros'
:
value
=
[
tuple
(
macro
.
split
(
'='
))
for
macro
in
value
]
self
.
values
[
key
]
=
value
if
source
is
not
None
:
for
line
in
line_iter
(
source
):
line
=
line
.
strip
()
if
line
!=
''
and
line
[
0
]
!=
'#'
:
break
line
=
line
[
1
:].
strip
()
if
line
[:
10
]
==
'distutils:'
:
line
=
line
[
10
:]
ix
=
line
.
index
(
'='
)
key
=
str
(
line
[:
ix
].
strip
())
value
=
line
[
ix
+
1
:].
strip
()
type
=
distutils_settings
[
key
]
if
type
in
(
list
,
transitive_list
):
value
=
parse_list
(
value
)
if
key
==
'define_macros'
:
value
=
[
tuple
(
macro
.
split
(
'='
))
for
macro
in
value
]
self
.
values
[
key
]
=
value
def
merge
(
self
,
other
):
for
key
,
value
in
other
.
values
.
items
():
...
...
@@ -101,6 +102,28 @@ class DistutilsInfo(object):
else
:
self
.
values
[
key
]
=
value
return
self
def
subs
(
self
,
aliases
):
if
aliases
is
None
:
return
self
resolved
=
DistutilsInfo
()
for
key
,
value
in
self
.
values
.
items
():
type
=
distutils_settings
[
key
]
if
type
in
[
list
,
transitive_list
]:
new_value_list
=
[]
for
v
in
value
:
if
v
in
aliases
:
v
=
aliases
[
v
]
if
isinstance
(
v
,
list
):
new_value_list
+=
v
else
:
new_value_list
.
append
(
v
)
value
=
new_value_list
else
:
if
value
in
aliases
:
value
=
aliases
[
value
]
resolved
.
values
[
key
]
=
value
return
resolved
def
strip_string_literals
(
code
,
prefix
=
'__Pyx_L'
):
...
...
@@ -280,8 +303,8 @@ class DependencyTree(object):
def
distutils_info0
(
self
,
filename
):
return
self
.
parse_dependencies
(
filename
)[
3
]
def
distutils_info
(
self
,
filename
):
return
self
.
transitive_merge
(
filename
,
self
.
distutils_info0
,
DistutilsInfo
.
merge
)
def
distutils_info
(
self
,
filename
,
aliases
):
return
self
.
transitive_merge
(
filename
,
self
.
distutils_info0
,
DistutilsInfo
.
merge
)
.
subs
(
aliases
)
def
transitive_merge
(
self
,
node
,
extract
,
merge
):
try
:
...
...
@@ -328,7 +351,7 @@ def create_dependency_tree(ctx=None):
# TODO: Take common options.
# TODO: Symbolic names (e.g. for numpy.include_dirs()
def
create_extension_list
(
filepatterns
,
ctx
=
None
):
def
create_extension_list
(
filepatterns
,
ctx
=
None
,
aliases
=
None
):
deps
=
create_dependency_tree
(
ctx
)
if
isinstance
(
filepatterns
,
str
):
filepatterns
=
[
filepatterns
]
...
...
@@ -337,7 +360,7 @@ def create_extension_list(filepatterns, ctx=None):
for
file
in
glob
(
pattern
):
pkg
=
deps
.
package
(
file
)
name
=
deps
.
fully_qualifeid_name
(
file
)
module_list
.
append
(
Extension
(
name
=
name
,
sources
=
[
file
],
**
deps
.
distutils_info
(
file
).
values
))
module_list
.
append
(
Extension
(
name
=
name
,
sources
=
[
file
],
**
deps
.
distutils_info
(
file
,
aliases
).
values
))
return
module_list
def
cythonize
(
module_list
,
ctx
=
None
,
nthreads
=
0
):
...
...
tests/build/inline_distutils.srctree
View file @
5266d1f9
...
...
@@ -10,12 +10,13 @@ from Cython.Compiler.Dependencies import create_extension_list, cythonize
from distutils.core import setup
setup(
ext_modules = cythonize(create_extension_list("*.pyx")),
ext_modules = cythonize(create_extension_list("*.pyx"
, aliases={'MATH_LIBS': ['m']}
)),
)
######## my_lib.pxd ########
# distutils: language=c++
# distutils: language = c++
# distutils: libraries = MATH_LIBS
cdef extern from "my_lib_helper.cpp" namespace "A":
int x
...
...
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