|
Original |
Translation |
|
143
|
There are two environment variables that can modify ``sys.path``. :envvar:`PYTHONHOME` sets an alternate value for the prefix of the Python installation. For example, if :envvar:`PYTHONHOME` is set to ``/www/python``, the search path will be set to ``['', '/www/python/lib/pythonX.Y/', '/www/python/lib/pythonX.Y/plat-linux2', ...]``.
|
|
|
144
|
The :envvar:`PYTHONPATH` variable can be set to a list of paths that will be added to the beginning of ``sys.path``. For example, if :envvar:`PYTHONPATH` is set to ``/www/python:/opt/py``, the search path will begin with ``['/www/python', '/opt/py']``. (Note that directories must exist in order to be added to ``sys.path``; the :mod:`site` module removes paths that don't exist.)
|
|
|
145
|
Finally, ``sys.path`` is just a regular Python list, so any Python application can modify it by adding or removing entries.
|
|
|
146
|
Distutils Configuration Files
|
|
|
147
|
As mentioned above, you can use Distutils configuration files to record personal or site preferences for any Distutils options. That is, any option to any command can be stored in one of two or three (depending on your platform) configuration files, which will be consulted before the command-line is parsed. This means that configuration files will override default values, and the command-line will in turn override configuration files. Furthermore, if multiple configuration files apply, values from "earlier" files are overridden by "later" files.
|
|
|
148
|
|
149
|
The names and locations of the configuration files vary slightly across platforms. On Unix and Mac OS X, the three configuration files (in the order they are processed) are:
|
|
|
150
|
|
|
|
151
|
|
|
|
152
|
:file:`{prefix}/lib/python{ver}/distutils/distutils.cfg`
|
|