Subsections

3 Install from Source Code

More familiarity with computers is required to build SAGE from source. If you do have all the tools, the process is relativley painless (but potentially time consuming), and has the advantage that you have the latest version of SAGE, and you can change absolutely any part of SAGE or the programs on which it depends and recompile.

Note: Solaris? FreeBSD?: Complete compilation of SAGE is currently not supported on Solaris or *BSD. It is possible to compile most of SAGE on Solaris machines and to fill in the extra parts using standard packages; please email wstein@gmail.com if you desparately need to run SAGE on Solarisq. (An issue with Solaris is that some components get compiled 64-bit and others 32-bit.)

Assumptions: You have a computer with about 850 megabytes disk space free running Linux (32-bit or 64-bit), OS X, or Cygwin/Windows1with development tools. In particular, the following standard command-line development tools must be installed on your box:

   gcc  (with C++ support)
   lexx (or flex)
   make
   m4 
   perl
   ranlib
   tar
   yacc (or bison)  -- relatively recent version.
To check if you have m4 installed, for example, type which m4 at a command line. If it gives an error (or returns nothing), then it is not installed. Note that bison is the free version of yacc, and flex is the free version of lexx.

Note: On Cygwin you must also install gnuplot and clisp (common lisp).

Note: You must have the GNU version of make installed. For example, SAGE won't build on a FreeBSD install that doesn't have the optional GNU version of make installed as well (and named make).

Although some of SAGE is written in Python, you do not need Python pre-installed on your computer, since the SAGE installation includes everything you need. When the installation program is run, it will check that you have each of the above-listed prerequisites, and inform you of any that are missing.

Note:

After extracting the SAGE tarball, the subdirectory source contains the source distributions for everything on which SAGE depends. We emphasize that all of this software is included with SAGE , so you do not have to worry about trying to download and install any one of these packages (such as GAP, for example) yourself.

Note: On tests using various Linux computer systems the known problems are:

3.1 Steps to Install from Source

Installation from source is (potentially) very easy, because the distribution contains (essentially) everything on which SAGE depends.

Note: Make sure there are no spaces in the directory name under which you build SAGE. Running SAGE from a directory with spaces in it is supported but discouraged. Building is not possible, since several of the components of SAGE do not build if there are spaces in the path. (This is a frequently issue for those compiling SAGE under Cygwin.)

  1. Download the file sage-*.tar from
      http://modular.math.washington.edu/SAGE/dist/src/index.html
    
    or from the scipy mirror,
      http://sage.scipy.org/sage/dist/src/
    
    This tarfile contains the source code for SAGE and the source for all programs on which SAGE depends. Download it into a subdirectory of your home directory into which you want to install SAGE. Note that this file is not compressed; it's just a plain tarball (which happens to be full of compressed files).

  2. Extract:
          tar xvf sage-x.y.z.tar
    

  3. This creates a directory sage-x.y.z.

  4. Change into that directory
          cd sage-x.y.z
    
    This is SAGE's home directory.

  5. Optional (but highly recommended): Read the README.txt file there.

  6. Type
          make
    
    This compiles SAGE and all dependencies. Note that you do not need to be logged in as root, since no files are changed outside of the sage-x.y.z directory.2 This command does the usual steps for each of the packages, but puts all the results in the local build tree. This can take close to an hour on some machines. If successful, you will not see the word ERROR in the last 3-4 lines of output.

    Note: The directory where you built SAGE is NOT hardcoded into any part of SAGE. You should be able to safely move or rename that directory. (It's a bug if this is not the case - unfortunately there is one bug which hasn't yet been fixed along these lines, namely the PARI install hard-codes the location of the "galois data" files. Fixes welcome!)

    After you build SAGE, you may optionally copy or move the entire build tree to /usr/local. You might also copy the sage-*/sage script to /usr/local/bin/ and edit ROOT="....." at the top of that file.

  7. To start SAGE change into the SAGE home directory and type:
          ./sage
    
    You should see the SAGE prompt, which will look something like this (starting SAGE the first time can take a few seconds):
    $ sage
    -------------------------------------------------------------------
    |  SAGE Version 0.10.1, Build Date: 2005-12-20-2026               |
    |  Distributed under the terms of the GNU General Public License  |
    |  For help type <object>?, <object>??, %magic, or help           |
    -------------------------------------------------------------------
    sage:
    
    Just starting SAGE successfully tests that many of the components built correctly. If the above is not displayed (e.g., if you get a massive traceback), please report the problem, e.g., to sage-forum@lists.sourceforge.net. Please include in your email the file install.log. It would also be helpful to include the type of operating system you have and the version number (and date) of the copy of SAGE you are using. (There are no formal requirements for bug reports - just send them; we appreciate everything.)

    After SAGE starts, try a command:

    sage: 2 + 2
    4
    

    Try something more complicated, which uses the PARI C library:

    sage: factor(2005)
    5 * 401
    

    Try something simple that uses the Gap, Singular, Maxima and GP/PARI interfaces:

    sage: gap('2+2')
    4
    sage: gp('2+2')
    4
    sage: maxima('2+2')
    4
    sage: singular('2+2')
    4
    sage: pari('2+2')
    4
    
    (For those familiar with GAP: SAGE automatically builds a GAP ``workspace'' during installation, so the response time from this GAP command is relatively fast. For those familiar with GP/PARI, the gp command creates an object in the GP interpreter, and the pari command creates an object directly in the PARI C-library.)

    Try running Gap, Singular or GP from SAGE:

    sage: gap_console()
    GAP4, Version: 4.4.6 of 02-Sep-2005, x86_64-unknown-linux-gnu-gcc
    gap> 2+2;
    4
    [ctrl-d]
    
    sage: gp_console()
    ...
    [ctrl-d]
    
    sage: singular_console()
                         SINGULAR                             /  Development
     A Computer Algebra System for Polynomial Computations   /   version 3-0-1
                                                           0<
         by: G.-M. Greuel, G. Pfister, H. Schoenemann        \   October 2005
    FB Mathematik der Universitaet, D-67653 Kaiserslautern    \
    // ** executing /usr/local/sage/sage-0.8.2/bin/LIB/.singularrc
    [ctrl-d]
    > Auf Wiedersehen.
    sage:
    

  8. Optional: Check the interfaces to any non-included software that you have available. Note that each interface calls its corresponding program by a particular name: Mathematica is invoked by calling math, Maple by calling maple, et cetera. The easiest way to change this name or perform other customizations is to create a redirection script in $SAGE_ROOT/local/bin. SAGE inserts this directory at the front of your PATH, so your script may need to use an absolute path to avoid calling itself; also, your script should use $* to pass along all of its arguments. For example, a maple script might look like:
    #!/bin/sh
    
    /etc/maple10.2/maple.tty $*
    

  9. Optional: Different possibilities to make using SAGE a little easier:

  10. Optional: Test the install by typing ./sage -testall. This runs most examples in the source code and makes sure that they run exactly as claimed. To test all examples, use ./sage -testall -optional -long; this will run examples that take a long time, and those that depend on optional packages and software, e.g., Mathematica or Magma. Some (optional) examples will likely fail because they assume that a database is installed.

  11. Optional: The directory spkg/build contains intermediate code that is used to build sage. Type make clean to delete it and a few other directories (e.g., spkg/archive and devel/old). This is safe and will save you about 500MB disk space. You may wish to type this periodically.

  12. Optional: Install optional SAGE packages and databases. Type sage -optional to see a list or visit http://modular.math.washington.edu/sage/packages/optional/, and sage -i <package name> to automatically download and install a given package.

Have fun! Discover some amazing conjectures!

3.2 Installation in a Multiuser Environment

This section addresses the question of how a system administrator can install a single copy of SAGE in a multi-user computer network.

3.2.1 System-wide install

This is a compilation of posts to the SAGE support list (in particular those of Luis Finotti).

  1. Unpack the current SAGE tarball (we shall assume it is sage-1.2.0.tar) at, e.g., /usr/local/ and compile it as root. Assuming you are in a root shell and the tarball is in your current directory, type:

    cp sage-1.2.0.tar /usr/local
    cd /usr/local
    tar xvf sage-1.2.0.tar 
    cd sage-1.2.0/
    make
    

    Comment: It's better to build in place. It's a bug if anything goes wrong when relocating the entire tarball - unfortunately there is one bug I haven't fixed along these lines, namely the PARI install hard-codes the location of the "galois data" files. (Fixes welcome!)

  2. Make sure to modify the line with the ``....."'s at the top of the sage script. In other words, edit SAGE_ROOT="....." to say SAGE_ROOT="/usr/local/sage-1.2.0".

  3. There are some initial files that have to be created during the first run of SAGE. Try starting up SAGE once as root (or, to be more thorough, try make test as root to run all the standard test code). You can stop the tests by pressing ctrl-z followed by typing kill %1 (assuming you had no other jobs in the background of that shell).

  4. Make a copy of the sage script in /usr/local/bin:
    cp /usr/local/sage-1.2.0/sage /usr/local/bin/
    
    You make a copy instead of a symlink, since upgrading SAGE (with sage -upgrade) overwrites /usr/local/sage-1.2.0/sage, hence deleting the ROOT=... part of that file.

    Make sure that all files in /usr/local/sage-1.2.0 are readable by all:

    chmod a+r -R /usr/local/sage-1.2.0
    



Footnotes

... Cygwin/Windows1
In Cygwin certain packages must be downgraded. See the README.txt.
... directory.2
There is one exception--the .ipythonrc directory is created in your HOME directory if it doesn't exist.
See About this document... for information on suggesting changes.