Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="inst.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="inst.html" title='Installing Python Modules' /> | |
8 | <link rel='last' href='about.html' title='About this document...' /> | |
9 | <link rel='help' href='about.html' title='About this document...' /> | |
10 | <link rel="next" href="search-path.html" /> | |
11 | <link rel="prev" href="standard-install.html" /> | |
12 | <link rel="parent" href="inst.html" /> | |
13 | <link rel="next" href="search-path.html" /> | |
14 | <meta name='aesop' content='information' /> | |
15 | <title>3 Alternate Installation</title> | |
16 | </head> | |
17 | <body> | |
18 | <DIV CLASS="navigation"> | |
19 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
20 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
21 | <tr> | |
22 | <td class='online-navigation'><a rel="prev" title="2 Standard Build and" | |
23 | href="standard-install.html"><img src='../icons/previous.png' | |
24 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
25 | <td class='online-navigation'><a rel="parent" title="Installing Python Modules" | |
26 | href="inst.html"><img src='../icons/up.png' | |
27 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
28 | <td class='online-navigation'><a rel="next" title="4 Custom Installation" | |
29 | href="search-path.html"><img src='../icons/next.png' | |
30 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
31 | <td align="center" width="100%">Installing Python Modules</td> | |
32 | <td class='online-navigation'><img src='../icons/blank.png' | |
33 | border='0' height='32' alt='' width='32' /></td> | |
34 | <td class='online-navigation'><img src='../icons/blank.png' | |
35 | border='0' height='32' alt='' width='32' /></td> | |
36 | <td class='online-navigation'><img src='../icons/blank.png' | |
37 | border='0' height='32' alt='' width='32' /></td> | |
38 | </tr></table> | |
39 | <div class='online-navigation'> | |
40 | <b class="navlabel">Previous:</b> | |
41 | <a class="sectref" rel="prev" href="standard-install.html">2 Standard Build and</A> | |
42 | <b class="navlabel">Up:</b> | |
43 | <a class="sectref" rel="parent" href="inst.html">Installing Python Modules</A> | |
44 | <b class="navlabel">Next:</b> | |
45 | <a class="sectref" rel="next" href="search-path.html">4 Custom Installation</A> | |
46 | </div> | |
47 | <hr /></div> | |
48 | </DIV> | |
49 | <!--End of Navigation Panel--> | |
50 | <div class='online-navigation'> | |
51 | <!--Table of Child-Links--> | |
52 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
53 | ||
54 | <UL CLASS="ChildLinks"> | |
55 | <LI><A href="alt-install-windows.html#SECTION000310000000000000000">3.1 Alternate installation: the home scheme</a> | |
56 | <LI><A href="alt-install-windows.html#SECTION000320000000000000000">3.2 Alternate installation: <span class="Unix">Unix</span> (the prefix scheme)</a> | |
57 | <LI><A href="alt-install-windows.html#SECTION000330000000000000000">3.3 Alternate installation: Windows (the prefix scheme)</a> | |
58 | </ul> | |
59 | <!--End of Table of Child-Links--> | |
60 | </div> | |
61 | <HR> | |
62 | ||
63 | <H1><A NAME="SECTION000300000000000000000"></A> | |
64 | <A NAME="alt-install"></A> | |
65 | <BR> | |
66 | 3 Alternate Installation | |
67 | </H1> | |
68 | ||
69 | <P> | |
70 | Often, it is necessary or desirable to install modules to a location | |
71 | other than the standard location for third-party Python modules. For | |
72 | example, on a <span class="Unix">Unix</span> system you might not have permission to write to the | |
73 | standard third-party module directory. Or you might wish to try out a | |
74 | module before making it a standard part of your local Python | |
75 | installation. This is especially true when upgrading a distribution | |
76 | already present: you want to make sure your existing base of scripts | |
77 | still works with the new version before actually upgrading. | |
78 | ||
79 | <P> | |
80 | The Distutils <code class="du-command">install</code> command is designed to make installing | |
81 | module distributions to an alternate location simple and painless. The | |
82 | basic idea is that you supply a base directory for the installation, and | |
83 | the <code class="du-command">install</code> command picks a set of directories (called an | |
84 | <em>installation scheme</em>) under this base directory in which to | |
85 | install files. The details differ across platforms, so read whichever | |
86 | of the following sections applies to you. | |
87 | ||
88 | <P> | |
89 | ||
90 | <H2><A NAME="SECTION000310000000000000000"></A> | |
91 | <A NAME="alt-install-prefix"></A> | |
92 | <BR> | |
93 | 3.1 Alternate installation: the home scheme | |
94 | </H2> | |
95 | ||
96 | <P> | |
97 | The idea behind the ``home scheme'' is that you build and maintain a | |
98 | personal stash of Python modules. This scheme's name is derived from | |
99 | the idea of a ``home'' directory on <span class="Unix">Unix</span>, since it's not unusual for | |
100 | a <span class="Unix">Unix</span> user to make their home directory have a layout similar to | |
101 | <span class="file">/usr/</span> or <span class="file">/usr/local/</span>. This scheme can be used by | |
102 | anyone, regardless of the operating system their installing for. | |
103 | ||
104 | <P> | |
105 | Installing a new module distribution is as simple as | |
106 | ||
107 | <P> | |
108 | <div class="verbatim"><pre> | |
109 | python setup.py install --home=<dir> | |
110 | </pre></div> | |
111 | ||
112 | <P> | |
113 | where you can supply any directory you like for the | |
114 | <b class="programopt">--home</b> option. On <span class="Unix">Unix</span>, lazy typists can just type a | |
115 | tilde (<code>~</code>); the <code class="du-command">install</code> command will | |
116 | expand this to your home directory: | |
117 | ||
118 | <P> | |
119 | <div class="verbatim"><pre> | |
120 | python setup.py install --home=~ | |
121 | </pre></div> | |
122 | ||
123 | <P> | |
124 | The <b class="programopt">--home</b> option defines the installation base | |
125 | directory. Files are installed to the following directories under the | |
126 | installation base as follows: | |
127 | <div class="center"><table class="realtable"> | |
128 | <thead> | |
129 | <tr> | |
130 | <th class="left" >Type of file</th> | |
131 | <th class="left" >Installation Directory</th> | |
132 | <th class="left" >Override option</th> | |
133 | </tr> | |
134 | </thead> | |
135 | <tbody> | |
136 | <tr><td class="left" valign="baseline">pure module distribution</td> | |
137 | <td class="left" ><span class="du-filevar">home</span><span class="file">/lib/python</span></td> | |
138 | <td class="left" ><b class="programopt">--install-purelib</b></td></tr> | |
139 | <tr><td class="left" valign="baseline">non-pure module distribution</td> | |
140 | <td class="left" ><span class="du-filevar">home</span><span class="file">/lib/python</span></td> | |
141 | <td class="left" ><b class="programopt">--install-platlib</b></td></tr> | |
142 | <tr><td class="left" valign="baseline">scripts</td> | |
143 | <td class="left" ><span class="du-filevar">home</span><span class="file">/bin</span></td> | |
144 | <td class="left" ><b class="programopt">--install-scripts</b></td></tr> | |
145 | <tr><td class="left" valign="baseline">data</td> | |
146 | <td class="left" ><span class="du-filevar">home</span><span class="file">/share</span></td> | |
147 | <td class="left" ><b class="programopt">--install-data</b></td></tr></tbody> | |
148 | </table></div> | |
149 | ||
150 | <P> | |
151 | ||
152 | <span class="versionnote">Changed in version 2.4: | |
153 | The <b class="programopt">--home</b> option used to be supported | |
154 | only on <span class="Unix">Unix</span>.</span> | |
155 | ||
156 | <P> | |
157 | ||
158 | <H2><A NAME="SECTION000320000000000000000"></A> | |
159 | <A NAME="alt-install-home"></A> | |
160 | <BR> | |
161 | 3.2 Alternate installation: <span class="Unix">Unix</span> (the prefix scheme) | |
162 | </H2> | |
163 | ||
164 | <P> | |
165 | The ``prefix scheme'' is useful when you wish to use one Python | |
166 | installation to perform the build/install (i.e., to run the setup | |
167 | script), but install modules into the third-party module directory of a | |
168 | different Python installation (or something that looks like a different | |
169 | Python installation). If this sounds a trifle unusual, it is--that's | |
170 | why the ``home scheme'' comes first. However, there are at least two | |
171 | known cases where the prefix scheme will be useful. | |
172 | ||
173 | <P> | |
174 | First, consider that many Linux distributions put Python in <span class="file">/usr</span>, | |
175 | rather than the more traditional <span class="file">/usr/local</span>. This is entirely | |
176 | appropriate, since in those cases Python is part of ``the system'' | |
177 | rather than a local add-on. However, if you are installing Python | |
178 | modules from source, you probably want them to go in | |
179 | <span class="file">/usr/local/lib/python2.<span class="du-filevar">X</span></span> rather than | |
180 | <span class="file">/usr/lib/python2.<span class="du-filevar">X</span></span>. This can be done with | |
181 | ||
182 | <P> | |
183 | <div class="verbatim"><pre> | |
184 | /usr/bin/python setup.py install --prefix=/usr/local | |
185 | </pre></div> | |
186 | ||
187 | <P> | |
188 | Another possibility is a network filesystem where the name used to write | |
189 | to a remote directory is different from the name used to read it: for | |
190 | example, the Python interpreter accessed as <span class="file">/usr/local/bin/python</span> | |
191 | might search for modules in <span class="file">/usr/local/lib/python2.<span class="du-filevar">X</span></span>, | |
192 | but those modules would have to be installed to, say, | |
193 | <span class="file">/mnt/<span class="du-filevar">@server</span>/export/lib/python2.<span class="du-filevar">X</span></span>. This | |
194 | could be done with | |
195 | ||
196 | <P> | |
197 | <div class="verbatim"><pre> | |
198 | /usr/local/bin/python setup.py install --prefix=/mnt/@server/export | |
199 | </pre></div> | |
200 | ||
201 | <P> | |
202 | In either case, the <b class="programopt">--prefix</b> option defines the | |
203 | installation base, and the <b class="programopt">--exec-prefix</b> option defines | |
204 | the platform-specific installation base, which is used for | |
205 | platform-specific files. (Currently, this just means non-pure module | |
206 | distributions, but could be expanded to C libraries, binary executables, | |
207 | etc.) If <b class="programopt">--exec-prefix</b> is not supplied, it defaults to | |
208 | <b class="programopt">--prefix</b>. Files are installed as follows: | |
209 | ||
210 | <P> | |
211 | <div class="center"><table class="realtable"> | |
212 | <thead> | |
213 | <tr> | |
214 | <th class="left" >Type of file</th> | |
215 | <th class="left" >Installation Directory</th> | |
216 | <th class="left" >Override option</th> | |
217 | </tr> | |
218 | </thead> | |
219 | <tbody> | |
220 | <tr><td class="left" valign="baseline">pure module distribution</td> | |
221 | <td class="left" ><span class="du-filevar">prefix</span><span class="file">/lib/python2.<span class="du-filevar">X</span>/site-packages</span></td> | |
222 | <td class="left" ><b class="programopt">--install-purelib</b></td></tr> | |
223 | <tr><td class="left" valign="baseline">non-pure module distribution</td> | |
224 | <td class="left" ><span class="du-filevar">exec-prefix</span><span class="file">/lib/python2.<span class="du-filevar">X</span>/site-packages</span></td> | |
225 | <td class="left" ><b class="programopt">--install-platlib</b></td></tr> | |
226 | <tr><td class="left" valign="baseline">scripts</td> | |
227 | <td class="left" ><span class="du-filevar">prefix</span><span class="file">/bin</span></td> | |
228 | <td class="left" ><b class="programopt">--install-scripts</b></td></tr> | |
229 | <tr><td class="left" valign="baseline">data</td> | |
230 | <td class="left" ><span class="du-filevar">prefix</span><span class="file">/share</span></td> | |
231 | <td class="left" ><b class="programopt">--install-data</b></td></tr></tbody> | |
232 | </table></div> | |
233 | ||
234 | <P> | |
235 | There is no requirement that <b class="programopt">--prefix</b> or | |
236 | <b class="programopt">--exec-prefix</b> actually point to an alternate Python | |
237 | installation; if the directories listed above do not already exist, they | |
238 | are created at installation time. | |
239 | ||
240 | <P> | |
241 | Incidentally, the real reason the prefix scheme is important is simply | |
242 | that a standard <span class="Unix">Unix</span> installation uses the prefix scheme, but with | |
243 | <b class="programopt">--prefix</b> and <b class="programopt">--exec-prefix</b> supplied by | |
244 | Python itself as <code>sys.prefix</code> and <code>sys.exec_prefix</code>. Thus, | |
245 | you might think you'll never use the prefix scheme, but every time you | |
246 | run <code>python setup.py install</code> without any other options, you're | |
247 | using it. | |
248 | ||
249 | <P> | |
250 | Note that installing extensions to an alternate Python installation has | |
251 | no effect on how those extensions are built: in particular, the Python | |
252 | header files (<span class="file">Python.h</span> and friends) installed with the Python | |
253 | interpreter used to run the setup script will be used in compiling | |
254 | extensions. It is your responsibility to ensure that the interpreter | |
255 | used to run extensions installed in this way is compatible with the | |
256 | interpreter used to build them. The best way to do this is to ensure | |
257 | that the two interpreters are the same version of Python (possibly | |
258 | different builds, or possibly copies of the same build). (Of course, if | |
259 | your <b class="programopt">--prefix</b> and <b class="programopt">--exec-prefix</b> don't even | |
260 | point to an alternate Python installation, this is immaterial.) | |
261 | ||
262 | <P> | |
263 | ||
264 | <H2><A NAME="SECTION000330000000000000000"></A> | |
265 | <A NAME="alt-install-windows"></A> | |
266 | <BR> | |
267 | 3.3 Alternate installation: Windows (the prefix scheme) | |
268 | </H2> | |
269 | ||
270 | <P> | |
271 | Windows has no concept of a user's home directory, and since the | |
272 | standard Python installation under Windows is simpler than under | |
273 | <span class="Unix">Unix</span>, the <b class="programopt">--prefix</b> option has traditionally been used | |
274 | to install additional packages in separate locations on Windows. | |
275 | ||
276 | <P> | |
277 | <div class="verbatim"><pre> | |
278 | python setup.py install --prefix="\Temp\Python" | |
279 | </pre></div> | |
280 | ||
281 | <P> | |
282 | to install modules to the | |
283 | <span class="file">\Temp\Python</span> directory on the | |
284 | current drive. | |
285 | ||
286 | <P> | |
287 | The installation base is defined by the <b class="programopt">--prefix</b> option; | |
288 | the <b class="programopt">--exec-prefix</b> option is not supported under Windows. | |
289 | Files are installed as follows: | |
290 | <div class="center"><table class="realtable"> | |
291 | <thead> | |
292 | <tr> | |
293 | <th class="left" >Type of file</th> | |
294 | <th class="left" >Installation Directory</th> | |
295 | <th class="left" >Override option</th> | |
296 | </tr> | |
297 | </thead> | |
298 | <tbody> | |
299 | <tr><td class="left" valign="baseline">pure module distribution</td> | |
300 | <td class="left" ><span class="du-filevar">prefix</span><span class="file"></span></td> | |
301 | <td class="left" ><b class="programopt">--install-purelib</b></td></tr> | |
302 | <tr><td class="left" valign="baseline">non-pure module distribution</td> | |
303 | <td class="left" ><span class="du-filevar">prefix</span><span class="file"></span></td> | |
304 | <td class="left" ><b class="programopt">--install-platlib</b></td></tr> | |
305 | <tr><td class="left" valign="baseline">scripts</td> | |
306 | <td class="left" ><span class="du-filevar">prefix</span><span class="file">\Scripts</span></td> | |
307 | <td class="left" ><b class="programopt">--install-scripts</b></td></tr> | |
308 | <tr><td class="left" valign="baseline">data</td> | |
309 | <td class="left" ><span class="du-filevar">prefix</span><span class="file">\Data</span></td> | |
310 | <td class="left" ><b class="programopt">--install-data</b></td></tr></tbody> | |
311 | </table></div> | |
312 | ||
313 | <P> | |
314 | ||
315 | <DIV CLASS="navigation"> | |
316 | <div class='online-navigation'> | |
317 | <p></p><hr /> | |
318 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
319 | <tr> | |
320 | <td class='online-navigation'><a rel="prev" title="2 Standard Build and" | |
321 | href="standard-install.html"><img src='../icons/previous.png' | |
322 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
323 | <td class='online-navigation'><a rel="parent" title="Installing Python Modules" | |
324 | href="inst.html"><img src='../icons/up.png' | |
325 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
326 | <td class='online-navigation'><a rel="next" title="4 Custom Installation" | |
327 | href="search-path.html"><img src='../icons/next.png' | |
328 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
329 | <td align="center" width="100%">Installing Python Modules</td> | |
330 | <td class='online-navigation'><img src='../icons/blank.png' | |
331 | border='0' height='32' alt='' width='32' /></td> | |
332 | <td class='online-navigation'><img src='../icons/blank.png' | |
333 | border='0' height='32' alt='' width='32' /></td> | |
334 | <td class='online-navigation'><img src='../icons/blank.png' | |
335 | border='0' height='32' alt='' width='32' /></td> | |
336 | </tr></table> | |
337 | <div class='online-navigation'> | |
338 | <b class="navlabel">Previous:</b> | |
339 | <a class="sectref" rel="prev" href="standard-install.html">2 Standard Build and</A> | |
340 | <b class="navlabel">Up:</b> | |
341 | <a class="sectref" rel="parent" href="inst.html">Installing Python Modules</A> | |
342 | <b class="navlabel">Next:</b> | |
343 | <a class="sectref" rel="next" href="search-path.html">4 Custom Installation</A> | |
344 | </div> | |
345 | </div> | |
346 | <hr /> | |
347 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
348 | </DIV> | |
349 | <!--End of Navigation Panel--> | |
350 | <ADDRESS> | |
351 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
352 | </ADDRESS> | |
353 | </BODY> | |
354 | </HTML> |