diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2012-08-07 14:19:18 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2012-08-07 14:19:18 +0200 |
commit | 6761654915f754ff268a74ac0ef9ff814a6e815e (patch) | |
tree | 47db580083340bb632766beb76da4eeee9786f5e /pyximport | |
parent | 31e7360087615d528f4aa7e2413e52aac99bf2b4 (diff) | |
download | cython-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.py | 7 |
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() |