Python - Namespace Package

Card Puncher Data Processing

About

Namespace packages allow you to split the sub-packages and modules within a single package across multiple, separate distribution packages

Example

mynamespace/
    __init__.py
    subpackage_a/
        __init__.py
        ...
    subpackage_b/
        __init__.py
        ...
    module_b.py
setup.py

And you use this package in your code like so:

from mynamespace import subpackage_a
from mynamespace import subpackage_b

Then you can break these sub-packages into two separate distributions:

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

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

Each sub-package can now be separately installed, used, and versioned.

Management

Packaging

In the Python - setup.py,

packages=find_packages(),
namespace_packages=['subPackage1', 'subPackage2', '...', 'subPackage3'],





Discover More
Card Puncher Data Processing
Python - setup.py

setup.py is a file found at the root directory of your project and serves two primary functions: configuration of the project command line interface for running various commands that relate to packaging...
Card Puncher Data Processing
Python - Package

in Python Physically, package are the directories and modules are the files within this directories. Logically, a package is a module (parent module): which can contain: modules (submodules)...



Share this page:
Follow us:
Task Runner