[Distutils] [setuptools] running a post_install script

Rick Ratzel rlratzel at enthought.com
Fri Aug 25 00:01:33 CEST 2006

>   >I've just been discovering the beauties of setuptools - for someone like
>   >me, developing a package with many dependencies, it could be just the
>   >tonic! And very easy to get going too - thnks!
>   >
>   >One question though - my package carries a post-install script to create
>   >a few shortcuts on windows systems. Creating an egg and then
>   >easy_installing it copies a setuptools version of the script to the
>   >scripts folder but it doesn't run at the end of install (or maybe it
>   >tries to and fails in some hidden way).
>   easy_install doesn't support post-install scripts, currently, as it's 
>   designed for installation of libraries rather than applications.
>   It's possible that some future version of easy_install could support a 
>   mechanism for various kinds of post-install hooks, in order to allow e.g. 
>   shortcut registration, registry entries, and the like.  The idea would be 
>   that a package would include metadata that describes the registration info 
>   needed, rather than including code to actually do the registration.  (The 
>   idea here being that we're not opening up for arbitrary code to run during 
>   installation.)
>   But at this point, such a feature is a rather long way off.  So for now, 
>   it's best to just instruct users how to run your postinstall script (which 
>   ideally should be given a name that's unique to your package, e.g. 
>   'foo-postinstall' if your package is named foo).

   Here at Enthought, we're developing an application which provides a graphical
user interface to easy_install which also adds additional features that we need
in order to deploy some of the libraries we use in egg form.  One of the
additional features we need is the ability to run post-install scripts.

   The application is named "Enstaller" and is currently available only as an
alpha right now, and only for Windows.  Enstaller will eventually be used as the
means for distributing "Python Enthought Edition".  At the moment, the stable
versions of Python Enthought Edition are distributed as a massive Wise .exe
installer...Enstaller allows users to pick and choose the individual packages
provided by Enthought rather than downloading several which they don't need.  It
also allows a user to browse and install from the Python Cheeseshop.

   In order to distribute the complete Python Enthought Edition in egg-form, we
had to make eggs for two applications which are bundled in the big .exe file:
Swig and MinGW.  The post-install scripts bundled with those eggs add their dirs
to the search PATH.  Another egg we have is for VTK, and it's post-install
script adds one of the dirs to the search PATH so it's .dlls are found.  Also,
our pywin32 egg has a post-install script which runs to do the various registry
mods that the pywin32 .exe installer does.

   Currently, only Enstaller knows how to run these post-install scripts.  If
the egg it just installed has a "post_install.py" script in EGG-INFO, it runs
it.  The post_install.py script calls, in an order defined at egg-build time,
the scripts in EGG-INFO/post_install.

   At the moment, this does allow for arbitrary code to run during install,
which has the potential to be bad.  We needed something to allow this given the
many diverse packages we offer in Python Enthought Edition though, but I imagine
future versions won't allow this and will instead be more like what Phillip
suggested by only allowing specific registration operations.

   If you'd like to check it out, the link to the Python 2.4.3 Enthought Edition
1.1.0 download page (has a link to a Python-2.4 .exe installer which runs
Enstaller at the end to add the Enthought Edition packages, as well a link to
the Enstaller bootstrap script if you wish to use an existing Python 2.4 Windows
install) is here:


   ...and the Enstaller wiki is here:


   Remember that a.) it's still alpha and undergoing frequent changes, and b.)
while it can run on other platforms, the packages it requires to get it properly
bootstrapped are only available for Windows and Python 2.4...that will change
soon though.

   Hope this helps!

Rick Ratzel - Enthought, Inc.
515 Congress Avenue, Suite 2100 - Austin, Texas 78701
512-536-1057 x229 - Fax: 512-536-1059

More information about the Distutils-SIG mailing list