annotate Doc/lib/libsite.tex @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 72986b716824
children 3468ea8645ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5261
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 \section{Standard Module \sectcode{site}}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 \stmodindex{site}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 Scripts or modules that need to use site-specific modules should
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 execute \code{import site} somewhere near the top of their code. This
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 will append up to two site-specific paths (\code{sys.prefix +
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 '/lib/site-python'} and
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 \code{sys.exec_prefix + '/lib/site-python'}) to the module search path.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 \code{sys.prefix} and \code{sys.exec_prefix} are configured when Python is installed; the default value is \file{/usr/local}.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 Because of Python's import semantics, it is okay for more than one
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 module to import \code{site} -- only the first one will execute the
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 site customizations. The directories are only appended to the path if
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 they exist and are not already on it.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 Sites that wish to provide site-specific modules should place them in
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 one of the site specific directories; \code{sys.prefix +
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 '/lib/site-python'} is for Python source code and
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 \code{sys.exec_prefix + '/lib/site-python'} is for dynamically
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 loadable extension modules (shared libraries).
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 After these path manipulations, an attempt is made to import a module
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 named \code{sitecustomize}, which can perform arbitrary site-specific
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 customizations. If this import fails with an \code{ImportError}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 exception, it is ignored.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 Note that for non-Unix systems, \code{sys.prefix} and
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 \code{sys.exec_prefix} are empty, and the path manipulations are
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 skipped; however the import of \code{sitecustomize} is still attempted.