How to run Sage in a systemwide Python
Create the run_sage bash script:
export SAGE_ROOT=/home/ondra/ext/sage export SAGE_LOCAL=$SAGE_ROOT/local export DOT_SAGE=~/.sage/ export PATH=$SAGE_ROOT/local/bin:$PATH export LD_LIBRARY_PATH="$SAGE_ROOT/local/lib/openmpi:$SAGE_ROOT/local/lib/:" export PYTHONPATH="$SAGE_ROOT/local/bin:$SAGE_ROOT/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg:$SAGE_ROOT/local/lib/python2.5/site-packages/SQLAlchemy-0.4.3-py2.5.egg:$SAGE_ROOT/local/bin:$SAGE_ROOT/local/lib/python:$SAGE_ROOT/local/lib/python25.zip:$SAGE_ROOT/local/lib/python2.5/plat-linux2:$SAGE_ROOT/local/lib/python2.5/lib-tk:$SAGE_ROOT/local/lib/python2.5/lib-dynload:$SAGE_ROOT/local/lib/python2.5/site-packages:$SAGE_ROOT/local/lib/python2.5/site-packages/IPython/Extensions" ipython
Then:
$ ./run_sage Python 2.5.1 (r251:54863, Mar 29 2008, 09:29:46) Type "copyright", "credits" or "license" for more information. IPython 0.8.1 -- An enhanced Interactive Python. ? -> Introduction to IPython's features. %magic -> Information about IPython's 'magic' % functions. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: from sage.all import * Falling back to a hard coded sage server in misc/hg.py In [2]: var("x") Out[2]: x In [3]: x**2/4 + log(x) Out[3]: log(x) + x^2/4
Now, if you don't want to setup so many things, create this s.py python script:
import os import sys def set_paths(): root = os.environ["SAGE_ROOT"] python_path = [ root+"/local/bin", root+"/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg", root+"/local/lib/python2.5/site-packages/SQLAlchemy-0.4.3-py2.5.egg", root+"/local/lib/python", root+"/local/lib/python25.zip", root+"/local/lib/python2.5/plat-linux2", root+"/local/lib/python2.5/lib-tk", root+"/local/lib/python2.5/lib-dynload", root+"/local/lib/python2.5/site-packages", root+"/local/lib/python2.5/site-packages/IPython/Extensions" ] paths = { "SAGE_LOCAL": root+"/local", "DOT_SAGE": "~/.sage/", "PATH": root+"/local/bin:"+os.environ["PATH"], } os.environ.update(paths) sys.path = python_path + sys.path set_paths() from sage.all import * var("x") print x**2/3-log(x)
and run it like this:
$ SAGE_ROOT=/home/ondra/ext/sage LD_LIBRARY_PATH="$SAGE_ROOT/local/lib/openmpi:$SAGE_ROOT/local/lib/:" python s.py Falling back to a hard coded sage server in misc/hg.py 2 x -- - log(x) 3