retire ofswiki
[iankelling.org] / technical-notes / setup.py-uninstall.md
1 ## Unix-like
2
3 Install over the existing installation with the same sources, recording installed files, then delete them.
4
5 ``` sh
6 sudo python setup.py install --record files.txt
7 # inspect files.txt to make sure it looks ok. Then in bash:
8 tr '\n' '\0' < files.txt | xargs -0 sudo rm -f --
9 ```
10
11 ## Windows
12
13 Install on top of the existing installation with a windows installer, then add-remove programs to uninstall.
14
15 ``` sh
16 python setup.py bdist_wininst
17 dist/foo-1.0.win32.exe
18 ```
19
20 ## Use other methods which fully support uninstall when available
21
22 Uninstalling setup.py install has some *inherent problems*, which usually aren't a problem:
23
24 - Files which a different package also depends on will be removed by uninstall
25 - Can't remove installed directories. --record only records non-directory files.
26 - If a file is installed which includes a newline, the command this page
27 recommends will fail. This won't happen except for a rare bug or a
28 malicious program. We could overcome this by using bdist_dumb, then
29 removing the files found in the archive which that command
30 builds. However, I'm no more confident of that command not having a
31 bug or edge case in which it would produce different files than a
32 normal install than I am of a package having a file with a newline in
33 it.
34
35 ### Alternatives
36
37 * pip
38 * python setup.py install bdist_rpm
39 * python setup.py bdist_wininst
40 * [official python recommendations](https://packaging.python.org/)
41
42 This page is also at [stackoverflow answer](http://stackoverflow.com/a/25209129/14456).
43
44 TODO: contribute this under https://wiki.python.org/moin/Distutils/Cookbook.