Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / inst / standard-install.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="inst.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="inst.html" title='Installing Python Modules' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="alt-install-windows.html" />
<link rel="prev" href="trivial-install.html" />
<link rel="parent" href="inst.html" />
<link rel="next" href="alt-install-windows.html" />
<meta name='aesop' content='information' />
<title>2 Standard Build and Install</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="1 Introduction"
href="trivial-install.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="Installing Python Modules"
href="inst.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 Alternate Installation"
href="alt-install-windows.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Installing Python Modules</td>
<td class='online-navigation'><img src='../icons/blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='../icons/blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='../icons/blank.png'
border='0' height='32' alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="trivial-install.html">1 Introduction</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="inst.html">Installing Python Modules</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="alt-install-windows.html">3 Alternate Installation</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<div class='online-navigation'>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL CLASS="ChildLinks">
<LI><A href="standard-install.html#SECTION000210000000000000000">2.1 Platform variations</a>
<LI><A href="standard-install.html#SECTION000220000000000000000">2.2 Splitting the job up</a>
<LI><A href="standard-install.html#SECTION000230000000000000000">2.3 How building works</a>
<LI><A href="standard-install.html#SECTION000240000000000000000">2.4 How installation works</a>
</ul>
<!--End of Table of Child-Links-->
</div>
<HR>
<H1><A NAME="SECTION000200000000000000000"></A>
<A NAME="standard-install"></A>
<BR>
2 Standard Build and Install
</H1>
<P>
As described in section&nbsp;<A href="trivial-install.html#new-standard">1.2</A>, building and installing
a module distribution using the Distutils is usually one simple command:
<P>
<div class="verbatim"><pre>
python setup.py install
</pre></div>
<P>
On <span class="Unix">Unix</span>, you'd run this command from a shell prompt; on Windows, you
have to open a command prompt window (``DOS box'') and do it there; on
Mac OS X, you open a <code class="du-command">Terminal</code> window to get a shell prompt.
<P>
<H2><A NAME="SECTION000210000000000000000"></A>
<A NAME="platform-variations"></A>
<BR>
2.1 Platform variations
</H2>
<P>
You should always run the setup command from the distribution root
directory, i.e. the top-level subdirectory that the module source
distribution unpacks into. For example, if you've just downloaded a
module source distribution <span class="file">foo-1.0.tar.gz</span> onto a
<span class="Unix">Unix</span> system, the normal thing to do is:
<P>
<div class="verbatim"><pre>
gunzip -c foo-1.0.tar.gz | tar xf - # unpacks into directory foo-1.0
cd foo-1.0
python setup.py install
</pre></div>
<P>
On Windows, you'd probably download <span class="file">foo-1.0.zip</span>. If you
downloaded the archive file to <span class="file">C:&#92;Temp</span>, then it
would unpack into <span class="file">C:&#92;Temp&#92;foo-1.0</span>;
you can use either a archive manipulator with a graphical user interface
(such as WinZip) or a command-line tool (such as <b class="program">unzip</b> or
<b class="program">pkunzip</b>) to unpack the archive. Then, open a command prompt
window (``DOS box''), and run:
<P>
<div class="verbatim"><pre>
cd c:\Temp\foo-1.0
python setup.py install
</pre></div>
<P>
<H2><A NAME="SECTION000220000000000000000"></A>
<A NAME="splitting-up"></A>
<BR>
2.2 Splitting the job up
</H2>
<P>
Running <code>setup.py install</code> builds and installs all modules in one
run. If you prefer to work incrementally--especially useful if you
want to customize the build process, or if things are going wrong--you
can use the setup script to do one thing at a time. This is
particularly helpful when the build and install will be done by
different users--for example, you might want to build a module distribution
and hand it off to a system administrator for installation (or do it
yourself, with super-user privileges).
<P>
For example, you can build everything in one step, and then install
everything in a second step, by invoking the setup script twice:
<P>
<div class="verbatim"><pre>
python setup.py build
python setup.py install
</pre></div>
<P>
If you do this, you will notice that running the <code class="du-command">install</code>
command first runs the <code class="du-command">build</code> command, which--in this
case--quickly notices that it has nothing to do, since everything in
the <span class="file">build</span> directory is up-to-date.
<P>
You may not need this ability to break things down often if all you do
is install modules downloaded off the 'net, but it's very handy for more
advanced tasks. If you get into distributing your own Python modules
and extensions, you'll run lots of individual Distutils commands on
their own.
<P>
<H2><A NAME="SECTION000230000000000000000"></A>
<A NAME="how-build-works"></A>
<BR>
2.3 How building works
</H2>
<P>
As implied above, the <code class="du-command">build</code> command is responsible for putting
the files to install into a <em>build directory</em>. By default, this is
<span class="file">build</span> under the distribution root; if you're excessively
concerned with speed, or want to keep the source tree pristine, you can
change the build directory with the <b class="programopt">--build-base</b> option.
For example:
<P>
<div class="verbatim"><pre>
python setup.py build --build-base=/tmp/pybuild/foo-1.0
</pre></div>
<P>
(Or you could do this permanently with a directive in your system or
personal Distutils configuration file; see
section&nbsp;<A href="config-syntax.html#config-files">5</A>.) Normally, this isn't necessary.
<P>
The default layout for the build tree is as follows:
<P>
<div class="verbatim"><pre>
--- build/ --- lib/
or
--- build/ --- lib.&lt;plat&gt;/
temp.&lt;plat&gt;/
</pre></div>
<P>
where <code>&lt;plat&gt;</code> expands to a brief description of the current
OS/hardware platform and Python version. The first form, with just a
<span class="file">lib</span> directory, is used for ``pure module distributions''--that
is, module distributions that include only pure Python modules. If a
module distribution contains any extensions (modules written in C/C++),
then the second form, with two <code>&lt;plat&gt;</code> directories, is used. In
that case, the <span class="file">temp.<span class="du-filevar">plat</span></span> directory holds temporary
files generated by the compile/link process that don't actually get
installed. In either case, the <span class="file">lib</span> (or
<span class="file">lib.<span class="du-filevar">plat</span></span>) directory contains all Python modules (pure
Python and extensions) that will be installed.
<P>
In the future, more directories will be added to handle Python scripts,
documentation, binary executables, and whatever else is needed to handle
the job of installing Python modules and applications.
<P>
<H2><A NAME="SECTION000240000000000000000"></A>
<A NAME="how-install-works"></A>
<BR>
2.4 How installation works
</H2>
<P>
After the <code class="du-command">build</code> command runs (whether you run it explicitly,
or the <code class="du-command">install</code> command does it for you), the work of the
<code class="du-command">install</code> command is relatively simple: all it has to do is copy
everything under <span class="file">build/lib</span> (or <span class="file">build/lib.<span class="du-filevar">plat</span></span>)
to your chosen installation directory.
<P>
If you don't choose an installation directory--i.e., if you just run
<code>setup.py install</code>--then the <code class="du-command">install</code> command installs to
the standard location for third-party Python modules. This location
varies by platform and by how you built/installed Python itself. On
<span class="Unix">Unix</span> (and Mac OS X, which is also Unix-based),
it also depends on whether the module distribution
being installed is pure Python or contains extensions (``non-pure''):
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Platform</th>
<th class="left" >Standard installation location</th>
<th class="left" >Default value</th>
<th class="center">Notes</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><span class="Unix">Unix</span> (pure)</td>
<td class="left" ><span class="file"><span class="du-filevar">prefix</span>/lib/python2.4/site-packages</span></td>
<td class="left" ><span class="file">/usr/local/lib/python2.4/site-packages</span></td>
<td class="center">(1)</td></tr>
<tr><td class="left" valign="baseline"><span class="Unix">Unix</span> (non-pure)</td>
<td class="left" ><span class="file"><span class="du-filevar">exec-prefix</span>/lib/python2.4/site-packages</span></td>
<td class="left" ><span class="file">/usr/local/lib/python2.4/site-packages</span></td>
<td class="center">(1)</td></tr>
<tr><td class="left" valign="baseline">Windows</td>
<td class="left" ><span class="file"><span class="du-filevar">prefix</span></span></td>
<td class="left" ><span class="file">C:&#92;Python</span></td>
<td class="center">(2)</td></tr></tbody>
</table></div>
<P>
Notes:
<DL>
<DT><STRONG>(1)</STRONG></DT>
<DD>Most Linux distributions include Python as a standard part of
the system, so <span class="du-filevar">prefix</span> and <span class="du-filevar">exec-prefix</span> are usually
both <span class="file">/usr</span> on Linux. If you build Python yourself on Linux (or
any <span class="Unix">Unix</span>-like system), the default <span class="du-filevar">prefix</span> and
<span class="du-filevar">exec-prefix</span> are <span class="file">/usr/local</span>.
</DD>
<DT><STRONG>(2)</STRONG></DT>
<DD>The default installation directory on Windows was
<span class="file">C:&#92;Program Files&#92;Python</span> under
Python 1.6a1, 1.5.2, and earlier.
</DD>
</DL>
<P>
<span class="du-filevar">prefix</span> and <span class="du-filevar">exec-prefix</span> stand for the directories
that Python is installed to, and where it finds its libraries at
run-time. They are always the same under Windows, and very
often the same under <span class="Unix">Unix</span>and Mac OS X. You can find out what your Python
installation uses for <span class="du-filevar">prefix</span> and <span class="du-filevar">exec-prefix</span> by
running Python in interactive mode and typing a few simple commands.
Under <span class="Unix">Unix</span>, just type <code>python</code> at the shell prompt. Under
Windows, choose <span class="guilabel">Start </span> &gt; <span class="guilabel">Programs </span> &gt; <span class="guilabel">Python
2.4</span> &gt; <span class="guilabel">Python (command line)</span>.
Once the interpreter is started, you type Python code at the
prompt. For example, on my Linux system, I type the three Python
statements shown below, and get the output as shown, to find out my
<span class="du-filevar">prefix</span> and <span class="du-filevar">exec-prefix</span>:
<P>
<div class="verbatim"><pre>
Python 2.4 (#26, Aug 7 2004, 17:19:02)
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import sys
&gt;&gt;&gt; sys.prefix
'/usr'
&gt;&gt;&gt; sys.exec_prefix
'/usr'
</pre></div>
<P>
If you don't want to install modules to the standard location, or if you
don't have permission to write there, then you need to read about
alternate installations in section&nbsp;<A href="alt-install-windows.html#alt-install">3</A>. If you want to
customize your installation directories more heavily, see
section&nbsp;<A href="search-path.html#custom-install">4</A> on custom installations.
<P>
<P>
<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="1 Introduction"
href="trivial-install.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="Installing Python Modules"
href="inst.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 Alternate Installation"
href="alt-install-windows.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Installing Python Modules</td>
<td class='online-navigation'><img src='../icons/blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='../icons/blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='../icons/blank.png'
border='0' height='32' alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="trivial-install.html">1 Introduction</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="inst.html">Installing Python Modules</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="alt-install-windows.html">3 Alternate Installation</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>