Package: setuphelper
This Python module will make your setup scripts simpler to
write, by automating as much as possible of the ‘boilerplate’
that normally goes into them. Instead of invoking thesetupfunction with a long list of keyword arguments, you just set
global variables in your setup script and then invoke thesetup_main function, passingglobals()as its argument.
(The SetupHelper setup.py script itself illustrates this usage.)The helper module does all the grunt work of translating your
variables into keyword arguments, including automatically
deducing and generating many arguments so that you only have
to specify a much simpler set of data. As a bonus, if you are
using Python’s standard distutils, SetupHelper provides (very
basic!) support for therequireskeyword, downloading and
installing required packages for you, as long as their download
URLs are available on PyPI. (You can also specify a local
directory as a “repository” by setting the environment
variablePYPI_LOCALto point to it–see theCHANGESfile in the source archive for details.) This functionality
currently doesnotsupport version specifiers after the
package name (unless you are using setuptools, which does
allow this–see below).(Note that the Python 2.5 and later distutils package allows
therequireskeyword in distribution metadata, but does
not actually use it to install anything for you. Of course
some distutils replacements like setuptools do provide this
functionality; if you are using setuptools, you can set the
variable__distutils_pkg__to'setuptools'and
SetupHelper will use setuptools’ support instead of its own,
which has some additional features, such as allowing version
specifiers for required packages. SetupHelper also adds therequires,provides, andobsoleteskeywords to
your package metadata when you use thesetup.py registercommand with Python versions < 2.5; in other words, it gives
you support for metadata version 1.1 even if your Python
version doesn’t.)Since SetupHelper has all the information needed to determine
what should be in your source or binary distribution files,
it auto-generatesMANIFEST.ineach time it runs, so you don’t
have to maintain yourMANIFEST.infile manually (and if you
did, it would get overwritten anyway). Even though it is not
strictly necessary to writeMANIFEST.inunless you are running
a distribution command, SetupHelper does it every time because
checking its output can often help you debug problems with the
variable definitions in your setup script. (At least, it has
certainly helpedmeto do that!)Using SetupHelper as an InstallerThis distribution includes a script,setuphelper, that you
can use to leverage SetupHelper’srequireskeyword support
to use it as an installer. Command line arguments to the
script are treated as a list of requirements to be installed,
and the script uses SetupHelper to download and install them,
just as if they were listed in asetup.pyscript. If you
want to use setuptools’easy_installsupport with this
technique, use the command line option--use-setuptools(short form-s).Since this script uses therequireskeyword functionality
in SetupHelper, it has the limitation noted above, that no
version specifiers can currently be used after package names.Post-Install Script SupportAs one other bonus, SetupHelper allows you to automate the
running of post-install scripts; just set the__post_install__variable in yoursetup.pyto a list of script names to be run
from a subshell (this is done usingos.system, so it has the
limitations of that Python command). It is desirable to allow
post-install scripts to be run fromsetup.pyso that SetupHelper
can ensure that any required packages are fully installed by
just callingpython setup.py installon them once they are
unpacked. (Note that, if you are using setuptools, this feature
does not work, as setuptools does not actually runpython setup.py installto install your package. A future
version of SetupHelper might lift this constraint.)Note that SetupHelper patches theinstall_scriptscommand indistutilsto capture the correct script installation directory.
This ensures that the correct version of your post-install scripts
(i.e., the one that just got installed) runs even if there are
multiple copies on your path.InstallationOf course, to install SetupHelper, you can simply type:$ python setup.py installin the directory where you unpacked the SetupHelper archive.
However, since SetupHelper is used by setup scripts, you will
probably want to include it along with yoursetup.pyin the
source archives for your Python projects as well as having it
installed on your own system.