The ability to uninstall packages installed by the install command is a long-time waited feature for distutils/setuptools. This document describe the design and features of such a facility.
An uninstall feature should be implemented for both distutils and setuptools: the setuptools uninstall command would then reuse the distutils one.
What should be the behavior of an uninstall command ?
- pure distutils (wo setuptools): only remove files installed by the install command from the same source tree.
- setuptools: should be able to remove eggs, deal with .pth.
- easy_install: may remove the dependencies (ala apt-get autoremove).
Problems to solve:
- how to record the files installed
- where to put the generated list of files
- how to decide which package location to remove
How to record the files installed
use the same facility as install --record to record the list of files to remove
Where to put the generated list
The list itself should be put in .egg-info (since it is built by both distutils and setuptools install command). The problem is how to get access to this list when several packages are installed (e.g. different site-packages, user vs system package, etc...). Several possible solutions:
- uninstall would take a record option, using the file generated by install --record. Can be a first step.
- put the location of the record in the build directory: hosed when the build directory is removed. But easy to get previously-installed location
- In the source tree itself ? Invasive. Easy to get last-installed location.
Removing last installed version is a useful feature for people who follow some projects from svn, and get caught when some modules are renamed inside the package.
Maybe another useful features:
python setup.py uninstall --prefix=path -> should remove the package installed with python setup.py install --prefix=path
- should be possible to avoid generating the record file (for OS distributors ?), although I am not sure whether this is useful. The rationale would be to avoid removing a system-wide package by accident. On OS with proper user protection, it won't be possible to do anything, and on windows, it is no worse than removing by rd-like commands, and requires the same effort.
- should deal with eggs, versions ?
- ability to remove a specified version
- based on setuptools uninstall
Central management for packages
A nice solution may be for python to have a centralized system to record installed packages. But how to deal with user python vs system python ? Putting some info into $HOME or equivalent cannot accomodate multiple python interpreters installed by users; putting them into a location 'owned' by the python interpreter is not usable when the python is system wide. More than likely to be hard to agree on implementation.
"What is needed by an uninstall command to be useful ?": http://email@example.com/msg05188.html
Patch for uninstall (deal with setuptools/easy_install only): http://bugs.python.org/setuptools/issue21