#
3 Writing the Setup Script

The setup script is the centre of all activity in building, distributing, and installing modules using the Distutils. The main purpose of the setup script is to describe your module distribution to the Distutils, so that the various commands that operate on your modules do the right thing. As we saw in section 2.1 above, the setup script consists mainly of a call to `setup()`, and most information supplied to the Distutils by the module developer is supplied as keyword arguments to `setup()`.

Here's a slightly more involved example, which we'll follow for the next couple of sections: the Distutils' own setup script. (Keep in mind that although the Distutils are included with Python 1.6 and later, they also have an independent existence so that Python 1.5.2 users can use them to install other module distributions. The Distutils' own setup script, shown here, is used to install the package into Python 1.5.2.)

      #!/usr/bin/env python

      from distutils.core import setup

      setup (name = "Distutils",
             version = "1.0",
             description = "Python Distribution Utilities",
             author = "Greg Ward",
             author_email = "gward@python.net",
             url = "http://www.python.org/sigs/distutils-sig/",

             packages = ['distutils', 'distutils.command'],
            )

There are only two differences between this and the trivial one-file distribution presented in section 2.1: more meta-data, and the specification of pure Python modules by package, rather than by module. This is important since the Distutils consist of a couple of dozen modules split into (so far) two packages; an explicit list of every module would be tedious to generate and difficult to maintain.

Note that any pathnames (files or directories) supplied in the setup script should be written using the Unix convention, i.e. slash-separated. The Distutils will take care of converting this platform-neutral representation into whatever is appropriate on your current platform before actually using the pathname. This makes your setup script portable across operating systems, which of course is one of the major goals of the Distutils. In this spirit, all pathnames in this document are slash-separated (Mac OS programmers should keep in mind that the absence of a leading slash indicates a relative path, the opposite of the Mac OS convention with colons).

Subsections

- 3.1 Listing whole packages
- 3.2 Listing individual modules
- 3.3 Describing extension modules
  - 3.3.1 Extension names and packages
  - 3.3.2 Extension source files
  - 3.3.3 Preprocessor options
  - 3.3.4 Library options