This chapter will take you through the basic steps
of installing &SCons; on your system,
and building &SCons; if you don't have a
pre-built package available
(or simply prefer the flexibility of building it yourself).
Before that, however, this chapter will also describe the basic steps
involved in installing Python on your system,
in case that is necessary.
Fortunately, both &SCons; and Python
are very easy to install on almost any system,
and Python already comes installed on many systems.
Installing Python
Because &SCons; is written in Python,
you must obviously have Python installed on your system
to use &SCons;.
Before you try to install Python,
you should check to see if Python is already
available on your system by typing
python -V
(capital 'V')
or
python --version
at your system's command-line prompt.
$ python -V
Python 2.5.1
And on a Windows system with Python installed:
C:\>python -V
Python 2.5.1
If Python is not installed on your system,
you will see an error message
stating something like "command not found"
(on UNIX or Linux)
or "'python' is not recognized
as an internal or external command, operable progam or batch file"
(on Windows).
In that case, you need to install Python
before you can install &SCons;.
The standard location for information
about downloading and installing Python is
http://www.python.org/download/.
See that page for information about
how to download and install Python on your system.
&SCons; will work with any 2.x version of Python from 2.4 on;
3.0 and later are not yet supported.
If you need to install Python and have a choice,
we recommend using the most recent 2.x Python version available.
Newer Pythons have significant improvements
that help speed up the performance of &SCons;.
Installing &SCons; From Pre-Built Packages
&SCons; comes pre-packaged for installation on a number of systems,
including Linux and Windows systems.
You do not need to read this entire section,
you should need to read only the section
appropriate to the type of system you're running on.
Installing &SCons; on Red Hat (and Other RPM-based) Linux Systems
&SCons; comes in RPM (Red Hat Package Manager) format,
pre-built and ready to install on Red Hat Linux,
Fedora,
or any other Linux distribution that uses RPM.
Your distribution may
already have an &SCons; RPM built specifically for it;
many do, including SUSE, Mandrake and Fedora.
You can check for the availability of an &SCons; RPM
on your distribution's download servers,
or by consulting an RPM search site like
http://www.rpmfind.net/ or
http://rpm.pbone.net/.
If your distribution supports installation via
yum,
you should be able to install &SCons; by running:
# yum install scons
If your Linux distribution does not already have
a specific &SCons; RPM file,
you can download and install from the
generic RPM provided by the &SCons; project.
This will install the
SCons script(s) in /usr/bin,
and the SCons library modules in
/usr/lib/scons.
To install from the command line, simply download the
appropriate .rpm file,
and then run:
# rpm -Uvh scons-2.2.0-1.noarch.rpm
Or, you can use a graphical RPM package manager.
See your package manager application's documention
for specific instructions about
how to use it to install a downloaded RPM.
Installing &SCons; on Debian Linux Systems
Debian Linux systems use a different package management
format that also makes it very easy to install &SCons;.
If your system is connected to the Internet,
you can install the latest official Debian package
by running:
# apt-get install sconsInstalling &SCons; on Windows Systems
&SCons; provides a Windows installer
that makes installation extremely easy.
Download the scons-2.2.0.win32.exe
file from the &SCons; download page at
http://www.scons.org/download.php.
Then all you need to do is execute the file
(usually by clicking on its icon in Windows Explorer).
These will take you through a small
sequence of windows that will install
&SCons; on your system.
Building and Installing &SCons; on Any System
If a pre-built &SCons; package is not available for your system,
then you can still easily build and install &SCons; using the native
Python distutils package.
The first step is to download either the
scons-2.2.0.tar.gz
or scons-2.2.0.zip,
which are available from the SCons download page at
http://www.scons.org/download.html.
Unpack the archive you downloaded,
using a utility like tar
on Linux or UNIX,
or WinZip on Windows.
This will create a directory called
scons-2.2.0,
usually in your local directory.
Then change your working directory to that directory
and install &SCons; by executing the following commands:
# cd scons-2.2.0
# python setup.py install
This will build &SCons;,
install the &scons; script
in the python which is used to run the setup.py's scripts directory
(/usr/local/bin or
C:\Python25\Scripts),
and will install the &SCons; build engine
in the corresponding library directory for the python used
(/usr/local/lib/scons or
C:\Python25\scons).
Because these are system directories,
you may need root (on Linux or UNIX) or Administrator (on Windows)
privileges to install &SCons; like this.
Building and Installing Multiple Versions of &SCons; Side-by-Side
The &SCons; setup.py script
has some extensions that support
easy installation of multiple versions of &SCons;
in side-by-side locations.
This makes it easier to download and
experiment with different versions of &SCons;
before moving your official build process to a new version,
for example.
To install &SCons; in a version-specific location,
add the option
when you call setup.py:
# python setup.py install --version-lib
This will install the &SCons; build engine
in the
/usr/lib/scons-2.2.0
or
C:\Python25\scons-2.2.0
directory, for example.
If you use the option
the first time you install &SCons;,
you do not need to specify it each time you install
a new version.
The &SCons; setup.py script
will detect the version-specific directory name(s)
and assume you want to install all versions
in version-specific directories.
You can override that assumption in the future
by explicitly specifying the option.
Installing &SCons; in Other Locations
You can install &SCons; in locations other than
the default by specifying the option:
# python setup.py install --prefix=/opt/scons
This would
install the scons script in
/opt/scons/bin
and the build engine in
/opt/scons/lib/scons,
Note that you can specify both the
and the options
at the same type,
in which case setup.py
will install the build engine
in a version-specific directory
relative to the specified prefix.
Adding to the
above example would install the build engine in
/opt/scons/lib/scons-2.2.0.
Building and Installing &SCons; Without Administrative Privileges
If you don't have the right privileges to install &SCons;
in a system location,
simply use the --prefix= option
to install it in a location of your choosing.
For example,
to install &SCons; in appropriate locations
relative to the user's $HOME directory,
the &scons; script in
$HOME/bin
and the build engine in
$HOME/lib/scons,
simply type:
$ python setup.py install --prefix=$HOME
You may, of course, specify any other location you prefer,
and may use the option
if you would like to install version-specific directories
relative to the specified prefix.
This can also be used to experiment with a newer
version of &SCons; than the one installed
in your system locations.
Of course, the location in which you install the
newer version of the &scons; script
($HOME/bin in the above example)
must be configured in your &PATH; variable
before the directory containing
the system-installed version
of the &scons; script.