[Tutor] Distutils

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Mon Feb 10 20:35:04 2003


> > Depending on your distribution requirements, it may or may not be
> > worth the effort to set up a distutils script to install your package
> > on new machines.  If it's a pure Python package, then all distutils
> > would be doing is copying it to a subdirectory of
> > [Python-home]\Lib\site-packages, which is easy enough to do
> > manually...
> >
>
> Setting up the distribution is not such an easy task. With the perl
> script, I thought it would be a piece of cake, but I am really strugging
> with writing the set-up script. For that reason, I wanted to make sure I
> knew how to do this with Python *before* the script was finished

Hi Paul,

(By the way, there was an article on Perl's MakeMaker system in a recent
edition of The Perl Journal, and the book "Computer Science and Perl
Programming" has a section on it in Chapter 42... (hmmm, that number comes
up a lot...))


I have some examples of Python scripts that have been "distutil"ed.  For
example, here's a pathetically puny one:

    http://hkn.eecs.berkeley.edu/~dyoo/python/__std__/


Organizing a set of modules to distribute to other folks via disutils
isn't actually that bad.  For the __std__ module above, I organized my
code into a package named "__std__".  I also cooked up a quicky 'setup.py'
file that tells Distutils what I'm packaging:

###
from distutils.core import setup
setup(name="__std__",
      version="1.0",
      author="Danny Yoo",
      author_email="dyoo@hkn.eecs.berkeley.edu",
      url="http://hkn.eecs.berkeley.edu/~dyoo/python/__std__/",
      packages=["__std__"]
      )
###


I think every keyword parameter in there is optional except for the 'name'
and 'packages' keywords... *grin* But if you'd like, I'm sure that someone
here can give a deeper introduction into Python's distutils system.  But
the official docs:

    http://python.org/dev/doc/devel/dist/dist.html

are decent.  Anyway, the small effort to 'Distutils' a package is worth it
in my mind, because it makes module installation convenient and consistant
for others.