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.

  1. Download the file sage-*.tar from
      http://www.sagemath.org/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.1 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 http://groups.google.com/group/sage-support. 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://www.sagemath.org/packages/optional/, and sage -i <package name> to automatically download and install a given package.

  13. Optional: Run the install_scripts command from in Sage to create gp, singular, gap, etc., scripts in your PATH. Type install_scripts? in Sage for details.

Have fun! Discover some amazing conjectures!



Footnotes

... directory.1
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.