How can I add post-install scripts to easy_install / setuptools / distutils?

It depends on how the user installs your package. If the user actually runs “setup.py install”, it’s fairly easy: Just add another subcommand to the install command (say, install_vim), whose run() method will copy the files you want in the places where you want them. You can add your subcommand to install.sub_commands, and pass the command into setup().

If you want a post-install script in a binary, it depends on the type of binary you are creating. For example, bdist_rpm, bdist_wininst, and bdist_msi have support for post-install scripts, because the underlying packing formats support post-install scripts.

bdist_egg doesn’t support a post-install mechanism by design:

http://bugs.python.org/setuptools/issue41

Leave a Comment