How-To's‎ > ‎Python‎ > ‎

Building Packages

This page is somewhat a tutorial. We will describe how to package the little project vizmdend
It is a good idea to create a repository. We used Github, which offers an amazing service for the price tag (it's free!)
Supporting tutorials on building packages are those of the Python package Index.

Package Structure

The package should follow a standard ordering when placing the files.

    + - - REAMDE.txt
    + - - LICENSE.txt
    + - - CHANGES.txt
    + - -
    + - - vizmdend/
            + - -
            + - -
            + - -

The script

The critical part is the script, which contains a call to the distutils.core.setup method.

One of the arguments passed to the distutils.core.setup method is the packages arguments, which in this case take the value packages = ['vizmdend',]. This indicates that vizmdend is not a single python module but a subdirectory containing many modules.

You must define the scope of your package by selecting one (or more) of the approved topic classifiers. Only the classifiers in the previous list are allowed !

The file

By default, distutils will include the following files in your release package:

  • README.txt
  • The .py files needed by the multi-file modules listed in the packages parameter
  • The individual .py files listed in the py_modules parameter
However, package vizmdend contains files required for the graphical interface that should be included. File instruct distutils to do just that. These files are located under the source subdirectory vizmdend/.

Checking the

In the command prompt: python check

Creating the Package

A source distributionpython sdist will create file MANIFEST containing the packaged files, as well as subdirectory dist/ containing the tarred package.

A windows graphical installer (NOTE: you will require a fairly recent build for python 2.7.3 in your system): python bdist_wininst will create the MANIFEST file as well as a windows executable *.exe within dist/ subdirectory. This executable is the installer.

Uploading to PYPI

If not already registered at PYPI, do so.

Register and upload your package: python register sdist bdist_wininst upload. When you release your project for the first time, Distutils will add your software to the Python Package Index and give it its own URL. Every time after that, it will simply update the project metadata with any changes you may have made in your parameters. Next, it builds a source distribution (sdist) and a Windows installer (bdist_wininst) then uploads them to PyPI (upload).

The address is , where NAME is the string you passed in the name parameter in your file.