GNU Info

Info Node: (python2.1-dist.info)Writing the Setup Script

(python2.1-dist.info)Writing the Setup Script


Next: Writing the Setup Configuration File Prev: Concepts & Terminology Up: Top
Enter node , (file) or (file)node

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~Note: A simple example
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~Note: A simple example: 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 (MacOS programmers should keep in
mind that the _absence_ of a leading slash indicates a relative path,
the opposite of the MacOS convention with colons).

This, of course, only applies to pathnames given to Distutils functions.
If you, for example, use standard python functions such as glob.glob or
os.listdir to specify files, you should be careful to write portable
code instead of hardcoding path separators:

         glob.glob(os.path.join('mydir', 'subdir', '*.html'))
         os.listdir(os.path.join('mydir', 'subdir'))

Listing whole packages
Listing individual modules
Describing extension modules
Listing scripts
Listing additional files

automatically generated by info2www version 1.2.2.9