rest25/library/site.rst => rest262/library/site.rst
21For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads
22are skipped.  For the tail part, it uses the empty string and then
23:file:`lib/site-packages` (on Windows) or
24:file:`lib/python|version|/site-packages` and then :file:`lib/site-python` (on
25Unix and Macintosh).  For each of the distinct head-tail combinations, it sees
26if it refers to an existing directory, and if so, adds it to ``sys.path`` and
27also inspects the newly added path for configuration files.
28
n29-.. index::
30-   single: package
31-   triple: path; configuration; file
32- 
33A path configuration file is a file whose name has the form :file:`package.pth`
34and exists in one of the four directories mentioned above; its contents are
35additional items (one per line) to be added to ``sys.path``.  Non-existing items
36are never added to ``sys.path``, but no check is made that the item refers to a
37directory (rather than a file).  No item is added to ``sys.path`` more than
38once.  Blank lines and lines beginning with ``#`` are skipped.  Lines starting
n39-with ``import`` are executed.
n35+with ``import`` (followed by space or tab) are executed.
36+ 
37+.. versionchanged:: 2.6
38+   A space or tab is now required after the import keyword.
39+ 
40+.. index::
41+   single: package
42+   triple: path; configuration; file
40
41For example, suppose ``sys.prefix`` and ``sys.exec_prefix`` are set to
n42-:file:`/usr/local`.  The Python |release| library is then installed in
n45+:file:`/usr/local`.  The Python X.Y library is then installed in
43-:file:`/usr/local/lib/python|version|` (where only the first three characters of
46+:file:`/usr/local/lib/python{X.Y}` (where only the first three characters of
44``sys.version`` are used to form the installation path name).  Suppose this has
n45-a subdirectory :file:`/usr/local/lib/python|version|/site-packages` with three
n48+a subdirectory :file:`/usr/local/lib/python{X.Y}/site-packages` with three
46subsubdirectories, :file:`foo`, :file:`bar` and :file:`spam`, and two path
47configuration files, :file:`foo.pth` and :file:`bar.pth`.  Assume
48:file:`foo.pth` contains the following::
49
50   # foo package configuration
51
52   foo
53   bar
54   bletch
55
56and :file:`bar.pth` contains::
57
58   # bar package configuration
59
60   bar
61
n62-Then the following directories are added to ``sys.path``, in this order::
n65+Then the following version-specific directories are added to
66+``sys.path``, in this order::
63
n64-   /usr/local/lib/python2.3/site-packages/bar
n68+   /usr/local/lib/pythonX.Y/site-packages/bar
65-   /usr/local/lib/python2.3/site-packages/foo
69+   /usr/local/lib/pythonX.Y/site-packages/foo
66
67Note that :file:`bletch` is omitted because it doesn't exist; the :file:`bar`
68directory precedes the :file:`foo` directory because :file:`bar.pth` comes
69alphabetically before :file:`foo.pth`; and :file:`spam` is omitted because it is
70not mentioned in either path configuration file.
71
72.. index:: module: sitecustomize
73
77ignored.
78
79.. index:: module: sitecustomize
80
81Note that for some non-Unix systems, ``sys.prefix`` and ``sys.exec_prefix`` are
82empty, and the path manipulations are skipped; however the import of
83:mod:`sitecustomize` is still attempted.
84
t89+ 
90+.. data:: PREFIXES
91+ 
92+   A list of prefixes for site package directories
93+ 
94+   .. versionadded:: 2.6
95+ 
96+ 
97+.. data:: ENABLE_USER_SITE
98+ 
99+   Flag showing the status of the user site directory. True means the
100+   user site directory is enabled and added to sys.path. When the flag
101+   is None the user site directory is disabled for security reasons.
102+ 
103+   .. versionadded:: 2.6
104+ 
105+ 
106+.. data:: USER_SITE
107+ 
108+   Path to the user site directory for the current Python version or None
109+ 
110+   .. versionadded:: 2.6
111+ 
112+ 
113+.. data:: USER_BASE
114+ 
115+   Path to the base directory for user site directories
116+ 
117+   .. versionadded:: 2.6
118+ 
119+ 
120+.. envvar:: PYTHONNOUSERSITE
121+ 
122+   .. versionadded:: 2.6
123+ 
124+ 
125+.. envvar:: PYTHONUSERBASE
126+ 
127+   .. versionadded:: 2.6
128+ 
129+ 
130+.. function:: addsitedir(sitedir, known_paths=None)
131+ 
132+   Adds a directory to sys.path and processes its pth files.
133+ 
134+ 
135+XXX Update documentation
136+XXX document python -m site --user-base --user-site
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op