5c870181e3cf91d4bb39c812d0e7ba1a9c668fa9
[iankelling.org] / _site / technical-notes / setup.py-uninstall.html
1 <!DOCTYPE html>
2 <html lang="en-US">
3 <head>
4 <meta charset="utf-8">
5 <title>setup.py uninstall</title>
6 <link rel="stylesheet" href="/css/main.css">
7 <link rel="shortcut icon" href="/assets/favicon.png" />
8 <meta name="description" content="Ian Kelling's personal site and blog on software">
9 <link rel="canonical" href="https://iankelling.org//technical-notes/setup.py-uninstall.html">
10
11 <meta name="viewport" content="width=device-width, initial-scale=1">
12 </head>
13 <body>
14 <header class="page_header">
15 <h3><a href="/">iankelling.org</a> / <a href="/technical-notes.html">technical notes</a> /</h3>
16 </header>
17 <div class="main-content-stripe">
18 <div class="prose">
19 <h1>setup.py uninstall</h1><b>Contents</b><ul>
20 <li>
21 <a href="#unix-like">Unix-like</a>
22 </li>
23 <li>
24 <a href="#windows">Windows</a>
25 </li>
26 <li>
27 <a href="#use-other-methods-which-fully-support-uninstall-when-available">Use other methods which fully support uninstall when available</a>
28 </li>
29 </ul>
30 <h2 id="unix-like">Unix-like</h2>
31
32 <p>Install over the existing installation with the same sources, recording installed files, then delete them.</p>
33 <div class="highlight"><pre>sudo python setup.py install --record files.txt
34 <span class="c1"># inspect files.txt to make sure it looks ok. Then in bash:</span>
35 tr <span class="s1">&#39;\n&#39;</span> <span class="s1">&#39;\0&#39;</span> &lt; files.txt <span class="p">|</span> xargs -0 sudo rm -f --
36 </pre></div>
37 <h2 id="windows">Windows</h2>
38
39 <p>Install on top of the existing installation with a windows installer, then add-remove programs to uninstall.</p>
40 <div class="highlight"><pre>python setup.py bdist_wininst
41 dist/foo-1.0.win32.exe
42 </pre></div>
43 <h2 id="use-other-methods-which-fully-support-uninstall-when-available">Use other methods which fully support uninstall when available</h2>
44
45 <p>Uninstalling setup.py install has some <em>inherent problems</em>, which usually aren&#39;t a problem:</p>
46
47 <ul>
48 <li>Files which a different package also depends on will be removed by uninstall</li>
49 <li>Can&#39;t remove installed directories. --record only records non-directory files.</li>
50 <li>If a file is installed which includes a newline, the command this page
51 recommends will fail. This won&#39;t happen except for a rare bug or a
52 malicious program. We could overcome this by using bdist_dumb, then
53 removing the files found in the archive which that command
54 builds. However, I&#39;m no more confident of that command not having a
55 bug or edge case in which it would produce different files than a
56 normal install than I am of a package having a file with a newline in
57 it.</li>
58 </ul>
59
60 <h3 id="alternatives">Alternatives</h3>
61
62 <ul>
63 <li>pip</li>
64 <li>python setup.py install bdist_rpm</li>
65 <li>python setup.py bdist_wininst</li>
66 <li><a href="https://packaging.python.org/">official python recommendations</a></li>
67 </ul>
68
69 <p>This page is also at <a href="http://stackoverflow.com/a/25209129/14456">stackoverflow answer</a>.</p>
70
71 <p>TODO: contribute this under https://wiki.python.org/moin/Distutils/Cookbook.</p>
72
73 </div>
74 </div>
75 <div class="comment-stripe">
76
77 </div>
78 <footer>
79
80 <p>Sources in <a href="/git/?p=iankelling.org;a=summary">git</a>. Mostly markdown files. Default is <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img class="cc-by-sa" alt="Creative Commons License" src="/assets/cc-by-sa-4.0-80x15.png" /></a></p>
81 <p><address><a href="mailto:ian@iankelling.org">ian@iankelling.org</a> let me know what you think</address></p>
82 </footer>
83 </body>
84 </html>