4. Creating a Source Distribution

Python 2.2

4. Creating a Source Distribution

As shown in section 1.2, you use the sdist command to create a source distribution. In the simplest case,

python setup.py sdist

(assuming you haven't specified any sdist options in the setup script or config file), sdist creates the archive of the default format for the current platform. The default format is a gzip'ed tar file (.tar.gz) on Unix, and ZIP file on Windows.

You can specify as many formats as you like using the --formats option, for example:

python setup.py sdist --formats=gztar,zip

to create a gzipped tarball and a zip file. The available formats are:

Format Description Notes
zip zip file (.zip) (1),(3)
gztar gzip'ed tar file (.tar.gz) (2),(4)
bztar bzip2'ed tar file (.tar.bz2) (4)
ztar compressed tar file (.tar.Z) (4)
tar tar file (.tar) (4)

Notes:

default on Windows
default on Unix
requires either external zip utility or zipfile module (part of the standard Python library since Python 1.6)
requires external utilities: tar and possibly one of gzip, bzip2, or compress


See About this document... for information on suggesting changes.