X-Git-Url: https://iankelling.org/git/?p=iankelling.org;a=blobdiff_plain;f=technical-notes%2Fsetup.py-uninstall.md;fp=technical-notes%2Fsetup.py-uninstall.md;h=dc8d05660c4bd11c4a52052a63820de19f687c15;hp=0000000000000000000000000000000000000000;hb=001299deacd7b5d230416aeda612ca7b40e13ffc;hpb=e81919074554ec1e719f1431667299c9c84dc854 diff --git a/technical-notes/setup.py-uninstall.md b/technical-notes/setup.py-uninstall.md new file mode 100644 index 0000000..dc8d056 --- /dev/null +++ b/technical-notes/setup.py-uninstall.md @@ -0,0 +1,44 @@ +## Unix-like + +Install over the existing installation with the same sources, recording installed files, then delete them. + +``` sh +sudo python setup.py install --record files.txt +# inspect files.txt to make sure it looks ok. Then in bash: +tr '\n' '\0' < files.txt | xargs -0 sudo rm -f -- +``` + +## Windows + +Install on top of the existing installation with a windows installer, then add-remove programs to uninstall. + +``` sh +python setup.py bdist_wininst +dist/foo-1.0.win32.exe +``` + +## Use other methods which fully support uninstall when available + +Uninstalling setup.py install has some *inherent problems*, which usually aren't a problem: + +- Files which a different package also depends on will be removed by uninstall +- Can't remove installed directories. --record only records non-directory files. +- If a file is installed which includes a newline, the command this page + recommends will fail. This won't happen except for a rare bug or a + malicious program. We could overcome this by using bdist_dumb, then + removing the files found in the archive which that command + builds. However, I'm no more confident of that command not having a + bug or edge case in which it would produce different files than a + normal install than I am of a package having a file with a newline in + it. + +### Alternatives + +* pip +* python setup.py install bdist_rpm +* python setup.py bdist_wininst +* [official python recommendations](https://packaging.python.org/) + +This page is also at [stackoverflow answer](http://stackoverflow.com/a/25209129/14456). + +TODO: contribute this under https://wiki.python.org/moin/Distutils/Cookbook.