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 at your system's command-line prompt. You should see something like the following on a UNIX or Linux system that has Python installed: $ python Python 2.2.2 (#1, Feb 24 2003, 19:13:11) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ^D And on a Windows system with Python installed: C:\>python Python 2.2.2 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ^Z The >>> is the input prompt for the Python interpreter. The ^D and ^Z represent the CTRL-D and CTRL-Z characters that you will need to type to get out of the interpreter before proceeding to installing &SCons;. 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.
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 only need to read 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 Core, 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 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-0.96-1.noarch.rpm Or, you can use a graphical RPM package manager like gnorpm. 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 scons
Installing &SCons; on Windows Systems &SCons; provides a Windows installer that makes installation extremely easy. Download the scons-0.95.win32.exe file from the &SCons; download page at http://www.scons.org/download.html. 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-__VERSION__.tar.gz or scons-__VERSION__.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-__VERSION__, usually in your local directory. Then change your working directory to that directory and install &SCons; by executing the following commands: # cd scons-__VERSION__ # python setup.py install This will build &SCons;, install the scons script in the default system scripts directory (/usr/local/bin or C:\Python2.2\Scripts), and will install the &SCons; build engine in an appropriate stand-alone library directory (/usr/local/lib/scons or C:\Python2.2\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-__VERSION__ or C:\Python2.2\scons-__VERSION__ 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-__VERSION__.
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.