Commit ed25f12b authored by Fedor Alekseev's avatar Fedor Alekseev Committed by GitHub

Support namespace packages inside regular packages (GH-3905)

parent c3121126
...@@ -156,9 +156,7 @@ def check_package_dir(dir_path, package_names): ...@@ -156,9 +156,7 @@ def check_package_dir(dir_path, package_names):
for dirname in package_names: for dirname in package_names:
dir_path = os.path.join(dir_path, dirname) dir_path = os.path.join(dir_path, dirname)
has_init = contains_init(dir_path) has_init = contains_init(dir_path)
if not namespace and not has_init: if has_init:
return None, False
elif has_init:
namespace = False namespace = False
return dir_path, namespace return dir_path, namespace
......
...@@ -10,7 +10,8 @@ from distutils.core import setup, Extension ...@@ -10,7 +10,8 @@ from distutils.core import setup, Extension
setup( setup(
ext_modules=cythonize([ ext_modules=cythonize([
Extension("nsp.m1.a", ["nsp/m1/a.pyx"]), Extension("nsp.m1.a", ["nsp/m1/a.pyx"]),
Extension("nsp.m2.b", ["nsp/m2/b.pyx"]) Extension("nsp.m2.b", ["nsp/m2/b.pyx"]),
Extension("nsp.m3.c.d", ["nsp/m3/c/d.pyx"]),
]), ]),
) )
...@@ -31,14 +32,28 @@ cdef class A: ...@@ -31,14 +32,28 @@ cdef class A:
######## nsp/m2/b.pyx ######## ######## nsp/m2/b.pyx ########
from nsp.m1.a cimport A from nsp.m1.a cimport A
from nsp.m3.c.d cimport D
cdef class B(A): cdef class B(A):
pass pass
######## nsp/m3/__init__.py ########
######## nsp/m3/c/d.pyx ########
cdef class D:
pass
######## nsp/m3/c/d.pxd ########
cdef class D:
pass
######## runner.py ######## ######## runner.py ########
from nsp.m1.a import A from nsp.m1.a import A
from nsp.m2.b import B from nsp.m2.b import B
from nsp.m3.c.d import D
a = A() a = A()
b = B() b = B()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment