I'm developing a python project that will have separately distributable parts.
I have been able to accomplish part of my goal by making a namespace package. I have "sub1" and "sub2", both in namespace "lvl1". I can pip install these in development mode using "pip install -e" or python setup.py develop
. I can import them with import lvl1.sub1
and import lvl1.sub2
.
However, the project is massive and calls for nested namespaces. I want to import lvl1.lvl2.sub1
and import lvl1.lvl2.sub2
. So both subpackages are in the same namespace ("lvl2"), which is itself in a namespace ("lvl1").
Desired conceptual structure:
lvl1/
lvl2/
sub1/
code.py
more_code.py
...
sub2/
code.py
...
Is there a way to do this and how?