What are virtual packages?
In a previous page you created your first development package. If you intend to develop only for you, that's all you need. But if you're thinking about publishing your packages, it may be convenient to develop all your packages under an empty package, to avoid name conflicts. But, on the other hand, you still want to keep a distinct development folder for every project. Welcome to virtual packages!
So, let's say that you decide that all your packages will be prefixed by blah. Here is how you set up your development folder for blah.mypackage:
# always activate the virtual environment
$ cd ~/myenv
$ source bin/activate
# create and initialize your development folder
$ mkdir blah.mypackage
$ cd blah.mypackage
$ buildout init
# prepare this folder for setuptools
$ touch setup.py
# create the source folder
$ mkdir -p src/blah/mypackage
# and make it a package
$ touch src/blah/__init__.py
$ touch src/blah/mypackage/__init__.py
but this time you need a spacial code inside src/blah/__init__.py to declare it a virtual package:
__import__('pkg_resources').declare_namespace(__name__)"
and also, you'll have to declare the virtual package in setup.py, adding the following line:
namespace_packages = ['blah'],
as a parameter in the setup invocation.
