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
Kirill Smelkov
cython
Commits
cfa48aec
Commit
cfa48aec
authored
Jun 19, 2017
by
Robert Bradshaw
Committed by
GitHub
Jun 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1654 from jdemeyer/include_dirs_from_externs
Automatically add include_dirs for externs
parents
c5a56e4b
8f71406d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
11 deletions
+49
-11
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+40
-9
tests/run/cimport_from_sys_path.srctree
tests/run/cimport_from_sys_path.srctree
+9
-2
No files found.
Cython/Build/Dependencies.py
View file @
cfa48aec
...
...
@@ -375,14 +375,30 @@ def normalize_existing(base_path, rel_paths):
@
cached_function
def
normalize_existing0
(
base_dir
,
rel_paths
):
"""
Given some base directory ``base_dir`` and a list of path names
``rel_paths``, normalize each relative path name ``rel`` by
replacing it by ``os.path.join(base, rel)`` if that file exists.
Return a couple ``(normalized, needed_base)`` where ``normalized``
if the list of normalized file names and ``needed_base`` is
``base_dir`` if we actually needed ``base_dir``. If no paths were
changed (for example, if all paths were already absolute), then
``needed_base`` is ``None``.
"""
normalized
=
[]
needed_base
=
None
for
rel
in
rel_paths
:
if
os
.
path
.
isabs
(
rel
):
normalized
.
append
(
rel
)
continue
path
=
join_path
(
base_dir
,
rel
)
if
path_exists
(
path
):
normalized
.
append
(
os
.
path
.
normpath
(
path
))
needed_base
=
base_dir
else
:
normalized
.
append
(
rel
)
return
normalized
return
(
normalized
,
needed_base
)
def
resolve_depends
(
depends
,
include_dirs
):
...
...
@@ -483,20 +499,25 @@ class DependencyTree(object):
return
all
@
cached_method
def
cimports_
and_extern
s
(
self
,
filename
):
def
cimports_
externs_incdir
s
(
self
,
filename
):
# This is really ugly. Nested cimports are resolved with respect to the
# includer, but includes are resolved with respect to the includee.
cimports
,
includes
,
externs
=
self
.
parse_dependencies
(
filename
)[:
3
]
cimports
=
set
(
cimports
)
externs
=
set
(
externs
)
incdirs
=
set
()
for
include
in
self
.
included_files
(
filename
):
included_cimports
,
included_externs
=
self
.
cimports_and_extern
s
(
include
)
included_cimports
,
included_externs
,
included_incdirs
=
self
.
cimports_externs_incdir
s
(
include
)
cimports
.
update
(
included_cimports
)
externs
.
update
(
included_externs
)
return
tuple
(
cimports
),
normalize_existing
(
filename
,
externs
)
incdirs
.
update
(
included_incdirs
)
externs
,
incdir
=
normalize_existing
(
filename
,
externs
)
if
incdir
:
incdirs
.
add
(
incdir
)
return
tuple
(
cimports
),
externs
,
incdirs
def
cimports
(
self
,
filename
):
return
self
.
cimports_
and_extern
s
(
filename
)[
0
]
return
self
.
cimports_
externs_incdir
s
(
filename
)[
0
]
def
package
(
self
,
filename
):
return
package
(
filename
)
...
...
@@ -579,12 +600,22 @@ class DependencyTree(object):
def
distutils_info0
(
self
,
filename
):
info
=
self
.
parse_dependencies
(
filename
)[
3
]
externs
=
self
.
cimports_and_externs
(
filename
)[
1
]
kwds
=
info
.
values
cimports
,
externs
,
incdirs
=
self
.
cimports_externs_incdirs
(
filename
)
# Add dependencies on "cdef extern from ..." files
if
externs
:
if
'depends'
in
info
.
value
s
:
info
.
values
[
'depends'
]
=
list
(
set
(
info
.
value
s
[
'depends'
]).
union
(
externs
))
if
'depends'
in
kwd
s
:
kwds
[
'depends'
]
=
list
(
set
(
kwd
s
[
'depends'
]).
union
(
externs
))
else
:
info
.
values
[
'depends'
]
=
list
(
externs
)
kwds
[
'depends'
]
=
list
(
externs
)
# Add include_dirs to ensure that the C compiler will find the
# "cdef extern from ..." files
if
incdirs
:
include_dirs
=
kwds
.
get
(
'include_dirs'
,
[])
for
inc
in
incdirs
:
if
inc
not
in
include_dirs
:
include_dirs
=
include_dirs
+
[
inc
]
kwds
[
'include_dirs'
]
=
include_dirs
return
info
def
distutils_info
(
self
,
filename
,
aliases
=
None
,
base
=
None
):
...
...
tests/run/cimport_from_sys_path.srctree
View file @
cfa48aec
...
...
@@ -19,8 +19,15 @@ setup(
######## site-packages/b/other.pxd ########
cdef inline foo(int a):
return a**2
cdef extern from "foo.c":
int foo(int)
######## site-packages/b/foo.c ########
static int foo(int a)
{
return a * a;
}
######## a.pyx ########
...
...
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