Python Notes (0.14.0)

7. Packaging

7.1. What is a package ?

A Python package alloas you to create a file directory structure of modules. It is a directory that contains the special file This file can be empty but must be present. Here is an example of a package contained in the a dicretory called Project:

└── Project
    ├── Package1

Although the __init__ file can be empty, it may be used to add statements. It may be used to import specific functions. ²

7.2. What is a project ?

In the structure above, the special file contains the mechanism that will allow you to build a project. A project may contain several packages.

The setup file can be written in different ways. Here is one example:

from distutils.core import setup

You can then install it by typing this command in a command line interface:

python install

Or create a distributable file (stored in dist/ directory):

python sdist


setuptools, pypi