@@ -78,20 +78,19 @@ \subsection{Best case: trivial installation}
7878Caldera, Corel, etc.), and so forth.
7979
8080In that case, you would download the installer appropriate to your
81- platform and do the usual thing with it: run it if it's an executable
82- installer, \code {rpm -I } it if it's an RPM, etc. You don't need to run
83- Python or a setup script, you don't need to compile anything---you might
84- not even need to read any instructions (although it's always a good idea
85- to do so anyways).
81+ platform and do the obvious thing with it: run it if it's an executable
82+ installer, \code {rpm --install } it if it's an RPM, etc. You don't need
83+ to run Python or a setup script, you don't need to compile
84+ anything---you might not even need to read any instructions (although
85+ it's always a good idea to do so anyways).
8686
8787Of course, things will not always be that easy. You might be interested
88- in a module distribution that nobody has created an easy-to-use
89- installer for use on your platform. In that case, you'll have to start
90- with the source distribution released by the module's
91- author/maintainer. Installing from a source distribution is not too
92- hard, as long as the modules are packaged in the standard way. The bulk
93- of this document is about building and installing modules that were
94- packaged in the standard way.
88+ in a module distribution that doesn't have an easy-to-use installer for
89+ your platform. In that case, you'll have to start with the source
90+ distribution released by the module's author/maintainer. Installing
91+ from a source distribution is not too hard, as long as the modules are
92+ packaged in the standard way. The bulk of this document is about
93+ building and installing modules from standard source distributions.
9594
9695
9796\subsection {The new standard: Distutils }
@@ -125,15 +124,17 @@ \subsection{The old way: no standards}
125124third-party modules in a consistent, standardized way. Thus, it's not
126125really possible to write a general manual for installing Python modules
127126that don't use the Distutils; the only truly general statement that can
128- be made is, `` Read the module's own documentation on installation.''
129-
130- However, such documentation is often woefully inadequate, assuming that
131- you are familiar with how the Python library is laid out and will
132- somehow just know where to copy various files in order for Python to
133- find them. Also, since there is only one way to lay out the Python
134- library on a given platform, this manual is a good place to learn that
135- layout. That way, if you do have to manually install an old,
136- pre-Distutils module distribution, you won't be completely on your own.
127+ be made is, `` Read the module's own installation instructions.''
128+
129+ However, if such instructions exists at all, they are often woefully
130+ inadequate and targeted at experienced Python developers. Such users
131+ are already familiar with how the Python library is laid out on their
132+ platform, and know where to copy various files in order for Python to
133+ find them. This document makes no such assumptions, and explains how
134+ the Python library is laid out on three major platforms (Unix, Windows,
135+ and Mac~OS), so that you can understand what happens when the Distutils
136+ do their job \emph {and } know how to install modules manually when the
137+ module author fails to provide a setup script.
137138
138139Additionally, while there has not previously been a standard
139140installation mechanism, Python has had some standard machinery for
@@ -158,8 +159,8 @@ \section{Standard Build and Install}
158159python setup.py install
159160\end {verbatim }
160161On Unix, you'd run this command from a shell prompt; on Windows, you
161- have to open a command prompt window and do it there; on Mac OS ...
162- \XXX {what the heck do you do on Mac OS?}.
162+ have to open a command prompt window and do it there; on Mac~ OS ...
163+ \XXX {what the heck do you do on Mac~ OS?}.
163164
164165
165166\subsection {Platform variations }
@@ -175,17 +176,20 @@ \subsection{Platform variations}
175176python setup.py install
176177\end {verbatim }
177178
178- On Windows, you'd probably unpack the archive before opening the command
179- prompt. If you downloaded the archive file to \file {C:\bslash {}Temp}, then
180- it probably unpacked (depending on your software) into
181- \file {C:\bslash {}Temp\bslash {}foo-1.0}; from the command prompt window, you would
182- then run
179+ On Windows, you'd probably unpack the archive before opening the command
180+ prompt. If you downloaded the archive file to \file {C:\bslash {}Temp},
181+ then it probably unpacked (depending on your software) into
182+ \file {C:\bslash {}Temp\bslash {}foo-1.0}; from the command prompt window,
183+ you would then run
183184\begin {verbatim }
184185cd c:\temp\foo-1.0
185186python setup.py install
186187\end {verbatim }
187188
188- On Mac OS, ... \XXX {again, how do you run Python scripts on Mac OS?}
189+ On Mac~OS, ... \XXX {again, how do you run Python scripts on Mac~OS?}
190+
191+ \XXX {arg, my lovely `` bslash'' macro doesn't work in non-tt fonts! help
192+ me \LaTeX , you're my only hope...}
189193
190194
191195\subsection {Splitting the job up }
@@ -202,49 +206,138 @@ \subsection{Splitting the job up}
202206python setup.py install
203207\end {verbatim }
204208(If you do this, you will notice that running the \command {install}
205- command first runs the \command {build} command, which will quickly
206- notice that it has nothing to do, since everything in the \file {build}
207- directory is up-to-date.
208-
209- % This will cover:
210- % * setup.py install (the usual thing)
211- % * setup.py build (if you like doing things one-at-a-time)
212- % * setup.py build install (not necessary unless you need to supply
213- % build options--ref. next section)
214- % * where things are installed, on Unix and Windows (Mac...?)
215- % * simple custom install: "install --prefix=$HOME"
216- \comingsoon
217-
218-
219-
220- % takes eight args (four pairs):
221- % pure module distribution base + directory
222- % non-pure module distribution base + directory
223- % script base + directory
224- % data base + directory
225- % ...and will no doubt take more args in future!
209+ command first runs the \command {build} command, which quickly notices
210+ that it has nothing to do, since everything in the \file {build}
211+ directory is up-to-date.)
212+
213+ \XXX {concrete reason for splitting things up?}
214+
215+
216+ \subsection {How building works }
217+
218+ As implied above, the \command {build} command is responsible for putting
219+ the files to install into a \emph {build directory }. By default, this is
220+ \file {build} under the distribution root; if you're excessively
221+ concerned with speed, or want to keep the source tree pristine, you can
222+ change the build directory with the \option {--build-base} option. For
223+ example:
224+ \begin {verbatim }
225+ python setup.py build --build-base=/tmp/pybuild/foo-1.0
226+ \end {verbatim }
227+ (Or you could do this permanently with a directive in your system or
228+ personal Distutils configuration file; see
229+ section~\ref {sec:config-files }.) Normally, this isn't necessary.
230+
231+ The default layout for the build tree is as follows:
232+ \begin {verbatim }
233+ --- build/ --- lib/
234+ or
235+ --- build/ --- lib.<plat>/
236+ temp.<plat>/
237+ \end {verbatim }
238+ where \code {<plat>} expands to a brief description of the current
239+ OS/hardware platform. The first form, with just a \file {lib} directory,
240+ is used for `` pure module distributions'' ---that is, module
241+ distributions that include only pure Python modules. If a module
242+ distribution contains any extensions (modules written in C/C++, or Java
243+ for JPython), then the second form, with two \code {<plat>} directories,
244+ is used. In that case, the \file {temp.\filevar {plat}} directory holds
245+ temporary files generated by the compile/link process that don't
246+ actually get installed. In either case, the \file {lib} (or
247+ \file {lib.\filevar {plat}}) directory contains all Python modules (pure
248+ Python and extensions) that will be installed.
249+
250+ In the future, more directories will be added to handle Python scripts,
251+ documentation, binary executables, and whatever else is needed to handle
252+ the job of installing Python modules and applicatins.
253+
254+
255+ \subsection {How installation works }
256+
257+ After the \command {build} command runs (whether you run it explicitly,
258+ or the \command {install} command does it for you), the work of the
259+ \command {install} command is relatively simple: all it has to do is copy
260+ everything under \file {build/lib} (or \file {build/lib.\filevar {plat}})
261+ to your chosen installation directory.
262+
263+ If you don't choose an installation directory---i.e., if you just run
264+ \code {setup.py install}---then the \command {install} command installs to
265+ the standard location for third-party Python modules. This location
266+ varies by platform and by how you built/installed Python itself. On
267+ Unix and Mac OS, it also depends on whether the module distribution
268+ being installed is pure Python or contains extensions (`` non-pure'' ):
269+ \begin {tableiii }{lll}{textrm}%
270+ {Platform}{Standard installation location}{Default value}
271+ \lineiii {Unix (pure Python modules)}
272+ {\file {\filevar {prefix}/lib/python1.6/site-packages}}
273+ {\file {/usr/local/lib/python1.6/site-packages}}
274+ \lineiii {Unix (non-pure distribution)}
275+ {\file {\filevar {exec-prefix}/lib/python1.6/site-packages}}
276+ {\file {/usr/local/lib/python1.6/site-packages}}
277+ \lineiii {Windows}
278+ {\filevar {prefix}}
279+ {\file {C:\bslash {}Python}
280+ \footnote {\file {C:\bslash {}Program Files\bslash {}Python}
281+ under Python 1.6a1 and earlier}}
282+ \lineiii {Mac~OS (pure Python modules)}
283+ {\file {\filevar {prefix}}:Lib}
284+ {\file {Python:Lib}\XXX {???}}
285+ \lineiii {Mac~OS (non-pure distribution)}
286+ {\file {\filevar {prefix}}:Mac:PlugIns}
287+ {\file {Python:Mac:PlugIns}\XXX {???}}
288+ \end {tableiii }
289+ \filevar {prefix} and \filevar {exec-prefix} stand for the directories
290+ that Python is installed to, and where it finds its libraries at
291+ run-time. They are always the same under Windows and Mac~OS, and very
292+ often the same under Unix. You can find out what your Python
293+ installation uses for \filevar {prefix} and \filevar {exec-prefix} by
294+ running Python in interactive mode and typing a few simple commands.
295+ Under Unix, just type \code {python} at the shell prompt; under Windows,
296+ run `` Python 1.6 (interpreter)'' \XXX {right?}; under Mac~OS, \XXX {???}.
297+ Once the interpreter is started, you type Python code at the \code {>>>}
298+ prompt. For example, on my Linux system, I type the three Python
299+ statements shown below, and get the output as shown, to find out my
300+ \filevar {prefix} and \filevar {exec-prefix}:
301+ \begin {verbatim }
302+ Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2
303+ Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
304+ >>> import sys
305+ >>> sys.prefix
306+ '/usr'
307+ >>> sys.exec_prefix
308+ '/usr'
309+ \end {verbatim }
310+
311+ If you don't want to install to the standard location, or if you don't
312+ have permission to write there, then you need to read about alternate
313+ installations in the next section.
314+
315+
316+ % This rather nasty macro is used to generate the tables that describe
317+ % each installation scheme. It's nasty because it takes two arguments
318+ % for each "slot" in an installation scheme, there will soon be more
319+ % than five of these slots, and TeX has a limit of 10 arguments to a
320+ % macro. Uh-oh.
321+
226322\newcommand {\installscheme }[8]
227323 {\begin {tableiii }{lll}{textrm}
228324 {Type of file}
229325 {Installation Directory}
230326 {Override option}
231327 \lineiii {pure module distribution}
232328 {\filevar {#1}\filenq {#2}}
233- {\option {install-purelib}}
329+ {\option {-- install-purelib}}
234330 \lineiii {non-pure module distribution}
235331 {\filevar {#3}\filenq {#4}}
236- {\option {install-platlib}}
332+ {\option {-- install-platlib}}
237333 \lineiii {scripts}
238334 {\filevar {#5}\filenq {#6}}
239- {\option {install-scripts}}
335+ {\option {-- install-scripts}}
240336 \lineiii {data}
241337 {\filevar {#7}\filenq {#8}}
242- {\option {install-data}}
338+ {\option {-- install-data}}
243339 \end {tableiii }}
244340
245-
246-
247-
248341\section {Alternate Installation }
249342\label {sec:alt-install }
250343
@@ -271,25 +364,22 @@ \subsection{Alternate installation: Unix (the home scheme)}
271364
272365Under Unix, there are two ways to perform an alternate installation.
273366The `` prefix scheme'' is similar to how alternate installation works
274- under Windows and Mac OS, but is not necessarily the most useful way to
367+ under Windows and Mac~ OS, but is not necessarily the most useful way to
275368maintain a personal Python library. Hence, we document the more
276369convenient and commonly useful `` home scheme'' first.
277370
278- The idea behind the `` home scheme'' is that you are building and
279- maintaining a personal stash of Python modules, probably under your home
280- directory. Installing a new module distribution is as simple as
281- \begin {verbatim }
282- python setup.py install --home # arg, doesn't work (getopt)
283- \end {verbatim }
284- or
371+ The idea behind the `` home scheme'' is that you build and maintain a
372+ personal stash of Python modules, probably under your home directory.
373+ Installing a new module distribution is as simple as
285374\begin {verbatim }
286375python setup.py install --home=<dir>
287376\end {verbatim }
288377where you can supply any directory you like for the \option {home}
289- option. If you don't supply a directory (as in the first example
290- above), the \command {install} command uses the \code {HOME} environment
291- variable (or your official home directory as supplied by the password
292- file, if \code {HOME} is not defined).
378+ option. Lazy typists can just type a tilde (\code {\tilde }); the
379+ \command {install} command will expand this to your home directory:
380+ \begin {verbatim }
381+ python setup.py install --home=~
382+ \end {verbatim }
293383
294384The \option {home} option defines the installation base directory. Files
295385are installed to the following directories under the installation base
@@ -363,10 +453,10 @@ \subsection{Alternate installation: Unix (the prefix scheme)}
363453interpreter used to run the setup script will be used in compiling
364454extensions. It is your responsibility to ensure that the interpreter
365455used to run extensions installed in this way is compatibile with the
366- interpreter used to build them. The best way to ensure this is that the
367- two interpreters are the same version of Python (possibly different
368- builds, or possibly copies of the same build). (Of course, if your
369- \option {prefix} and \option {exec-prefix} don't even point to an
456+ interpreter used to build them. The best way to do this is to ensure
457+ that the two interpreters are the same version of Python (possibly
458+ different builds, or possibly copies of the same build). (Of course, if
459+ your \option {prefix} and \option {exec-prefix} don't even point to an
370460alternate Python installation, this is immaterial.)
371461
372462
@@ -393,10 +483,10 @@ \subsection{Alternate installation: Windows}
393483 {prefix}{\bslash {}Data}
394484
395485
396- \subsection {Alternate installation: Mac OS }
486+ \subsection {Alternate installation: Mac~ OS }
397487\label {sec:alt-macos }
398488
399- Like Windows, Mac OS has no notion of home directories (or even of
489+ Like Windows, Mac~ OS has no notion of home directories (or even of
400490users), and a fairly simple standard Python installation. Thus, only a
401491\option {prefix} option is needed. It defines the installation base, and
402492files are installed under it as follows:
@@ -478,13 +568,13 @@ \section{Custom Installation}
478568
479569If you want to define an entire installation scheme, you just have to
480570supply all of the installation directory options. The recommended way
481- to do this is to supply relative paths; for example, if want to maintain
482- all Python module-related files under \file {python} in your home
483- directory, and you want a separate directory for each platform that you
484- use your home directory from, you might define the following
571+ to do this is to supply relative paths; for example, if you want to
572+ maintain all Python module-related files under \file {python} in your
573+ home directory, and you want a separate directory for each platform that
574+ you use your home directory from, you might define the following
485575installation scheme:
486576\begin {verbatim }
487- python setup.py install --home \
577+ python setup.py install --home=~ \
488578 --install-purelib=python/lib \
489579 --install-platlib=python/lib.$PLAT \
490580 --install-scripts=python/scripts
@@ -536,27 +626,29 @@ \section{Custom Installation}
536626You probably noticed the use of \code {\$ HOME} and \code {\$ PLAT} in the
537627sample configuration file input. These are Distutils configuration
538628variables, which bear a strong resemblance to environment variables. In
539- fact, you can use environment variables in config files, but the
540- Distutils additionally define a few extra variables that may not be in
541- your environment, such as \code {\$ PATH}. See
629+ fact, you can use environment variables in config files---on platforms
630+ that have such a notion---but the Distutils additionally define a few
631+ extra variables that may not be in your environment, such as
632+ \code {\$ PLAT}. (And of course, you can only use the configuration
633+ variables supplied by the Distutils on systems that don't have
634+ environment variables, such as Mac~OS (\XXX {true?}).) See
542635section~\ref {sec:config-files } for details.
543636
544- \XXX {need some Windows and Mac OS examples---when would custom
637+ \XXX {need some Windows and Mac~ OS examples---when would custom
545638 installation schemes be needed on those platforms?}
546639
547640
548641\section {Distutils Configuration Files }
549642\label {sec:config-files }
550643
551- \comingsoon
552-
644+ \XXX {not even implemented yet, much less documented!}
553645
554646
555647\section {Pre-Distutils Conventions }
556648\label {sec:pre-distutils }
557649
558650
559- \subsection {The \protect\file { Makefile.pre.in} file }
651+ \subsection {The Makefile.pre.in file }
560652\label {sec:makefile-pre-in }
561653
562654
0 commit comments