Packaging with Python

· by

Contents
This is a quick article I have had as a draft for quite a while. It might not be finished or have other problems, but I still want to share it. I wrote this when I did not know much about packaging. I wrote a tutorial on how to create Python packages in 2018 as well. In 2020, I gave a Python Packaging Course which is better structured, up-to-date and has way more details.

The following article is a wrap-up of the talk Python Packages by Daniel Hepper, given at the German PyCon 2013.

PyPI is the Python Package Index. They distribute packages in the form of "eggs". You can install them with easy_install or with pip.

Package Management Tools

Distutils

Distutils is part of the standard library. When you run

python setup.py install

then distutils is running.

Major disadvantages of distutils are:

  • No metadata:
  • no uninstallation
  • no dependencies
  • No package listing (so you can't automatically search PyPI)

Setuptools

Setuptools is an extension for distutils. Setuptools offers dependency management. With setuptools, so-called 'egg files' were introduced. Those files are comparable to jar files in Java.

Distribute

Distribute was a fork of setuptools that got merged back into setuptools. So don't use distribute, use setuptools.

PIP and Creating packages

See Python Packaging Course

Environments

See Virtual Environments