From 6761654915f754ff268a74ac0ef9ff814a6e815e Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 7 Aug 2012 14:19:18 +0200 Subject: when pyximporting a package __init__ module in place, make sure we provide __path__ at module init time to support relative imports --- pyximport/pyxbuild.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'pyximport') 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() -- cgit v1.2.1