How is it possible build multiple python modules sharing the same namespace compatible for Python 2.7+ and 3.3+?
Let's call the namespace test
. Now I want to have two seperate modules called test.foo
and another one called test.bar
. However, I'm currently developing test.helloworld
which depends on both, test.foo
and test.bar
. Both are listed in the requirements.txt
file.
The modules test.foo
and test.bar
are currently using the Python 2 solution for namespace packages:
import pkg_resources
pkg_resources.declare_namespace(__name__)
Running the suggested pip-command for development mode pip install -e .
turns into: ImportError: No module named 'test.helloworld'
while importing test.foo
or test.bar
is working.
The Python 3 solution for namespace packages are Implicit Namespace Packages where the namespace package has no __init__.py
file. This is sadly not working for Python 2 versions.
How can I design a solution for both Python 2 and 3 (which allows me to use pip install -e .
)? The --egg
solution does not work for me since it is already deprecated.