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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
725c588d
Commit
725c588d
authored
Feb 24, 2012
by
Mark
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #91 from bfroehle/sys_path_pxd
Search for pxd files in sys.path.
parents
6f343d9c
b9aaa805
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+5
-2
tests/run/cimport_from_sys_path.srctree
tests/run/cimport_from_sys_path.srctree
+31
-0
No files found.
Cython/Compiler/Main.py
View file @
725c588d
...
@@ -182,7 +182,7 @@ class Context(object):
...
@@ -182,7 +182,7 @@ class Context(object):
# the directory containing the source file is searched first
# the directory containing the source file is searched first
# for a dotted filename, and its containing package root
# for a dotted filename, and its containing package root
# directory is searched first for a non-dotted filename.
# directory is searched first for a non-dotted filename.
pxd
=
self
.
search_include_directories
(
qualified_name
,
".pxd"
,
pos
)
pxd
=
self
.
search_include_directories
(
qualified_name
,
".pxd"
,
pos
,
sys_path
=
True
)
if
pxd
is
None
:
# XXX Keep this until Includes/Deprecated is removed
if
pxd
is
None
:
# XXX Keep this until Includes/Deprecated is removed
if
(
qualified_name
.
startswith
(
'python'
)
or
if
(
qualified_name
.
startswith
(
'python'
)
or
qualified_name
in
(
'stdlib'
,
'stdio'
,
'stl'
)):
qualified_name
in
(
'stdlib'
,
'stdio'
,
'stl'
)):
...
@@ -221,13 +221,16 @@ class Context(object):
...
@@ -221,13 +221,16 @@ class Context(object):
return
path
return
path
def
search_include_directories
(
self
,
qualified_name
,
suffix
,
pos
,
def
search_include_directories
(
self
,
qualified_name
,
suffix
,
pos
,
include
=
False
):
include
=
False
,
sys_path
=
False
):
# Search the list of include directories for the given
# Search the list of include directories for the given
# file name. If a source file position is given, first
# file name. If a source file position is given, first
# searches the directory containing that file. Returns
# searches the directory containing that file. Returns
# None if not found, but does not report an error.
# None if not found, but does not report an error.
# The 'include' option will disable package dereferencing.
# The 'include' option will disable package dereferencing.
# If 'sys_path' is True, also search sys.path.
dirs
=
self
.
include_directories
dirs
=
self
.
include_directories
if
sys_path
:
dirs
=
dirs
+
sys
.
path
if
pos
:
if
pos
:
file_desc
=
pos
[
0
]
file_desc
=
pos
[
0
]
if
not
isinstance
(
file_desc
,
FileSourceDescriptor
):
if
not
isinstance
(
file_desc
,
FileSourceDescriptor
):
...
...
tests/run/cimport_from_sys_path.srctree
0 → 100644
View file @
725c588d
PYTHON setup.py build_ext --inplace
PYTHON -c "import a"
######## setup.py ########
from Cython.Build import cythonize
from distutils.core import setup
# Add ./site-packages to sys.path
from os.path import realpath
import sys
sys.path.append(realpath('site-packages'))
setup(
ext_modules = cythonize("*.pyx"),
)
######## site-packages/b/__init__.py ########
######## site-packages/b/other.pxd ########
cdef inline foo(int a):
return a**2
######## a.pyx ########
from b.other cimport foo
print foo(10)
cimport b.other
print b.other.foo(10)
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