'Create a Master Package by combining multiple packages into a single distribution using setup.py in python

Hi I am following the documentation to create a namespace package like this.

namespace package

However, I would like to create a master package that combines these packages and install them from a single wheel without changing the import statements.

The folder structure is like this:

master 
setup.py
mynamespace-subpackage-a/
    setup.py
    mynamespace/
        subpackage_a/
            __init__.py

mynamespace-subpackage-b/
    setup.py
    mynamespace/
        subpackage_b/
            __init__.py
        module_b.py

I am able to create a distribution but the problem is that the import statement changes

from mynamespace import subpackage_a -> from master. mynamespace import subpackage_a

I would like to keep it from mynamespace import subpackage_a

Is there anyway I can create a master package keeping the import statements same?

I run python setup.py bdist_wheel from /master



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source