Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Quick Python: Package Namespacing

Published on

Updated on

Package namespacing can help organize modules within a larger project. It can also help show that a package belongs to an organization.

For example, let’s say you want to have a module named companyname.component. Then you want to have the following project structure.

companyname/
  component/
    __init__.py
    ...
setup.py

Note that there is no __init__.py under companyname.

Then in your setup.py denote where to find the packages using a namespace.

from setuptools import setup, find_namespace_packages

setup(name="companyname.component",
     version="0.0.1",
     packages=find_namespace_packages(include=["companyname.*"]))
Reply via Email

Have you published a response to this? :