Search code examples
pythonpipsetuptoolspython-wheel

Post install script after installing a wheel


Using from setuptools.command.install import install, I can easily run a custom post-install script if I run python setup.py install. This is fairly trivial to do.

Currently, the script does nothing but print some text but I want it to deal with system changes that need to happen when a new package is installed -- for example, back up the database that the package is using.

I want to generate the a Python wheel for my package and then copy that and install it on a a set of deployment machines. However, my custom install script is no longer run on the deployment machine.

What am I doing wrong? Is that even possible?


Solution

  • PEP 427 which specifies the wheel package format does not leave any provisions for custom pre or post installation scripts.

    Therefore running a custom script is not possible during wheel package installation.

    You'll have to add the custom script to a place in your package where you expect the developer to execute first.