04.08.2014 Views

o_18ufhmfmq19t513t3lgmn5l1qa8a.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

374 CHAPTER 18 ■ PACKAGING YOUR PROGRAMS<br />

■Note The extra values you set here are used for several things. The name and version keywords, for<br />

example, are used for naming archive files, and the author and description keywords end up in a file<br />

called PKG-INFO in any archives you build.<br />

You don’t really have to supply all of this information in the setup function (you don’t<br />

actually have to supply any arguments at all), and you certainly can supply more (such as<br />

author_email or url). The names should be self-explanatory. In the following sections, you’ll<br />

see what you can use this simple script for.<br />

Basic Installation<br />

Name your script setup.py (this is a universal convention for Distutils setup scripts), and make<br />

sure that you have a simple module called hello.py in the same directory.<br />

■Caution The setup script will create new files and subdirectories in the current directory when you run it,<br />

so you should probably experiment with it in a fresh directory to avoid having old files being overwritten.<br />

Now execute the script, like this:<br />

python setup.py<br />

You should get some output like the following:<br />

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]<br />

or: setup.py --help [cmd1 cmd2 ...]<br />

or: setup.py --help-commands<br />

or: setup.py cmd --help<br />

error: no commands supplied<br />

As you can see, you can get more information using the --help or --help-commands switches.<br />

Try to use the build command, just to see Distutils in action:<br />

python setup.py build<br />

You should now see output like the following:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!