-
Notifications
You must be signed in to change notification settings - Fork 7
Namespaces
We decided to use PEP420 native namespace packages from now on in Openalea, since we only maintain Python with versions superior to 3.3, and so all namespaces packages must follow this format.
It means that you need to omit the __init.py__
in the main package. However, you will still need to add the __init__.py
in the subpackages.
In Python, Namespaces packages are quite useful to easily import packages via pip install
, python install
, or conda install
.
They are divided in 3 types :
- pkg_ressources
- pkgutil
- Native namespace packages (aka PEP420 and PyPA)
The main difference is that a __init__.py
file can be absent from Native namespaces, while mandatory for the others.
The path of a Native namespace namespace will be like :
setup.py
openalea/
core/
__init__.py
file.py
vpltk/
While other will be like :
setup.py
openalea/
__init__.py
core/
__init__.py
file.py
vpltk/
Also, pkg_ressources and pkgutil namespaces are compatible with Python 2, and pkg_ressources is dependant on SetupTools to work.
Currently, OpenAlea uses pkg_ressources nspkg. They were used back in Python 2, and now they can cause compatibility problems when different modules from the same namespaces are installed using different commands.
from setuptools import setup, find_namespace_packages
setup(
name='alinea.caribu',
...
packages=find_namespace_packages(where='src', include=['alinea', 'alinea.*'], exclude=[]),
...
)