summaryrefslogtreecommitdiff
path: root/pyximport
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2012-08-07 14:19:18 +0200
committerStefan Behnel <stefan_ml@behnel.de>2012-08-07 14:19:18 +0200
commit6761654915f754ff268a74ac0ef9ff814a6e815e (patch)
tree47db580083340bb632766beb76da4eeee9786f5e /pyximport
parent31e7360087615d528f4aa7e2413e52aac99bf2b4 (diff)
downloadcython-6761654915f754ff268a74ac0ef9ff814a6e815e.tar.gz
when pyximporting a package __init__ module in place, make sure we provide __path__ at module init time to support relative imports
Diffstat (limited to 'pyximport')
-rw-r--r--pyximport/pyxbuild.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/pyximport/pyxbuild.py b/pyximport/pyxbuild.py
index 3218f6d22..498607e3f 100644
--- a/pyximport/pyxbuild.py
+++ b/pyximport/pyxbuild.py
@@ -57,6 +57,13 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
args.append("--force")
if inplace and package_base_dir:
args.extend(['--build-lib', package_base_dir])
+ if ext.name == '__init__' or ext.name.endswith('.__init__'):
+ # package => provide __path__ early
+ if not hasattr(ext, 'cython_directives'):
+ ext.cython_directives = {'set_initial_path_from_source' : True}
+ elif 'set_initial_path_from_source' not in ext.cython_directives:
+ ext.cython_directives['set_initial_path_from_source'] = True
+
if HAS_CYTHON and build_in_temp:
args.append("--pyrex-c-in-temp")
sargs = setup_args.copy()