Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / module-site.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-user.html" />
<link rel="prev" href="module-new.html" />
<link rel="parent" href="python.html" />
<link rel="next" href="module-user.html" />
<meta name='aesop' content='information' />
<title>3.30 site -- Site-specific configuration hook</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3.29 new "
href="module-new.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
href="python.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="3.31 user "
href="module-user.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-new.html">3.29 new </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-user.html">3.31 user </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0053000000000000000000">
3.30 <tt class="module">site</tt> --
Site-specific configuration hook</A>
</H1>
<P>
<A NAME="module-site"></A>
<P>
<strong>This module is automatically imported during initialization.</strong>
The automatic import can be suppressed using the interpreter's
<b class="programopt">-S</b> option.
<P>
Importing this module will append site-specific paths to the module
search path.
<a id='l2h-800' xml:id='l2h-800'></a>
<P>
It starts by constructing up to four directories from a head and a
tail part. For the head part, it uses <code>sys.prefix</code> and
<code>sys.exec_prefix</code>; empty heads are skipped. For
the tail part, it uses the empty string (on Windows) or
<span class="file">lib/python2.4/site-packages</span> (on <span class="Unix">Unix</span> and Macintosh)
and then <span class="file">lib/site-python</span>. For each of the distinct
head-tail combinations, it sees if it refers to an existing directory,
and if so, adds it to <code>sys.path</code> and also inspects the newly added
path for configuration files.
<a id='l2h-801' xml:id='l2h-801'></a><a id='l2h-802' xml:id='l2h-802'></a>
<P>
A path configuration file is a file whose name has the form
<span class="file"><var>package</var>.pth</span> and exists in one of the four directories
mentioned above; its contents are additional items (one
per line) to be added to <code>sys.path</code>. Non-existing items are
never added to <code>sys.path</code>, but no check is made that the item
refers to a directory (rather than a file). No item is added to
<code>sys.path</code> more than once. Blank lines and lines beginning with
<code>#</code> are skipped. Lines starting with <code>import</code> are executed.
<a id='l2h-804' xml:id='l2h-804'></a>
<a id='l2h-803' xml:id='l2h-803'></a>
<P>
For example, suppose <code>sys.prefix</code> and <code>sys.exec_prefix</code> are
set to <span class="file">/usr/local</span>. The Python 2.4.2 library is then
installed in <span class="file">/usr/local/lib/python2.4</span> (where only the
first three characters of <code>sys.version</code> are used to form the
installation path name). Suppose this has a subdirectory
<span class="file">/usr/local/lib/python2.4/site-packages</span> with three
subsubdirectories, <span class="file">foo</span>, <span class="file">bar</span> and <span class="file">spam</span>, and two
path configuration files, <span class="file">foo.pth</span> and <span class="file">bar.pth</span>. Assume
<span class="file">foo.pth</span> contains the following:
<P>
<div class="verbatim"><pre>
# foo package configuration
foo
bar
bletch
</pre></div>
<P>
and <span class="file">bar.pth</span> contains:
<P>
<div class="verbatim"><pre>
# bar package configuration
bar
</pre></div>
<P>
Then the following directories are added to <code>sys.path</code>, in this
order:
<P>
<div class="verbatim"><pre>
/usr/local/lib/python2.3/site-packages/bar
/usr/local/lib/python2.3/site-packages/foo
</pre></div>
<P>
Note that <span class="file">bletch</span> is omitted because it doesn't exist; the
<span class="file">bar</span> directory precedes the <span class="file">foo</span> directory because
<span class="file">bar.pth</span> comes alphabetically before <span class="file">foo.pth</span>; and
<span class="file">spam</span> is omitted because it is not mentioned in either path
configuration file.
<P>
After these path manipulations, an attempt is made to import a module
named <tt class="module">sitecustomize</tt><a id='l2h-805' xml:id='l2h-805'></a>, which can
perform arbitrary site-specific customizations. If this import fails
with an <tt class="exception">ImportError</tt> exception, it is silently ignored.
<P>
Note that for some non-<span class="Unix">Unix</span> systems, <code>sys.prefix</code> and
<code>sys.exec_prefix</code> are empty, and the path manipulations are
skipped; however the import of
<tt class="module">sitecustomize</tt><a id='l2h-806' xml:id='l2h-806'></a> is still attempted.
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3.29 new "
href="module-new.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
href="python.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="3.31 user "
href="module-user.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-new.html">3.29 new </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-user.html">3.31 user </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>