I want to run some custom code when I run pip uninstall
, cleaning up files that were created on installation. How should I go about this?
I've got custom install code running by using the following in setup.py:
from setuptools import setup
from setuptools.command.install import install
class CustomInstallCommand(install):
def run(self):
#Custom code here
install.run(self)
...
setup(
...
cmdclass = {
'install':CustomInstallCommand
}
)
But trying something similar for setuptools.command.uninstall
or from setuptools.command.install import uninstall
fails, since those modules/names don't exist.
As others stated: this is strongly discouraged for security reasons and even if you find a way to do it now, is likely to break in the near feature.
The same applies to setup install commands, not only uninstall ones. So, please don't go this route.
Python packaging (including pip) is going towards being totally delarative without running any code from the managed packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With