How to develop programs with Python Namespaced Packages?

In Python, a namespace package allows you to spread Python code among several projects. This is useful when you want to release related libraries as separate downloads. For example, with the directories Package-1 and Package-2 in PYTHONPATH,

the end-user can import namespace.module1 and import namespace.module2.

On Python 3.3, you don't have to do anything, just don't put any in your namespace package directories and it will just work. This is because Python 3.3 introduces implicit namespace packages.

On older versions, there's a standard module, called pkgutil, with which you can 'append' modules to a given namespace. You should put those two lines in both Package-1/namespace/ and Package-2/namespace/
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

This will add to the package's __path__ all subdirectories of directories on sys.path named after the package. After this you can distribute the 2 packages separately and leverage python namespaced packages.