You can't use implicit namespace packages (PEP 420 layout) in Python versions older than 3.3. Still, the concept of namespace packages is very old and was commonly used for years in such mature projects such as Zope. It means that it is definitely possible to use namespace packages in older version of Python. Actually, there are several ways to define that the package should be treated as a namespace.
The simplest one is to create a file structure for each component that resembles an ordinary package layout without implicit namespace packages and leave everything to setuptools. So, the example layout for acme.sql and acme.templating could be the following:
$ tree acme.sql/
acme.sql/
├── acme
│ ├── __init__.py
│ └── sql
│ └── __init__.py
└── setup.py
2 directories, 3 files
$ tree acme.templating/
acme.templating/
├── acme
│ ├── __init__.py
│ └── templating
│ └── __init__.py
└── setup.py
2 directories, 3 files
Note that for both acme.sql and acme.templating, there is an additional source file, acme/__init__.py. This file must be left empty. The acme namespace package will be created if we provide its name as a value of the namespace_packages keyword argument of the setuptools.setup() function as follows:
from setuptools import setup setup( name='acme.templating', packages=['acme.templating'], namespace_packages=['acme'], )
Easiest does not mean best. The setuptools module in order to register a new namespace will call for the pkg_resources.declare_namespace() function in your __init__.py file. It will happen even if the __init__.py file is empty. Anyway, as the official documentation says, it is your own responsibility to declare namespaces in the __init__.py file, and this implicit behavior of setuptools may be dropped in the future. In order to be safe and future-proof, you need to add the following line to the acme/__init__.py file:
__import__('pkg_resources').declare_namespace(__name__)
This line will make your namespace package safe from potential future changes regarding namespace packages in the setuptools module.
Let's see how to upload a package in the next section.