Difference between revisions of "Sage"
m (→Install 2.10.3) |
m (→Install 2.11) |
||
Line 203: | Line 203: | ||
<br>and modified the path in /usr/local/bin/sage |
<br>and modified the path in /usr/local/bin/sage |
||
<br>I also ran <code>make test</code> and that was ok. |
<br>I also ran <code>make test</code> and that was ok. |
||
+ | <br>But on a second machine I got an error at compile time, g++ killed. That was due to exhaused memory so I stopped the Sage notebook during the compilation of the new version and it went fine. |
||
− | |||
− | But on a second machine I got an error at compile time :-( ONGOING... |
||
TODO: transfer the optional packages |
TODO: transfer the optional packages |
Revision as of 17:58, 1 April 2008
Installations & upgrades
Initial installation 2.10
Some notes on the installation of Sage (v2.10) in a vserver:
Create a vserver, remove tmpfs /tmp in /etc/vservers/sage/fstab as 16M is too short for compilation
Create an account for the compilation
# adduser --disabled-password --shell /bin/false sage
Install packages needed for the compilation + some for runtime
# apt-get install gcc-4.1-base make m4 bison flex tar perl binutils \ libstdc++6-dev g++ openssh-client \ less screen imagemagick
Download and compile sources
# cd /opt # export http_proxy=http://proxy....:8080 # wget http://www.sagemath.org/dist/src/sage-2.10.tar # tar xf sage-2.10.tar # chown -R sage:sage * # su -s /bin/bash - sage sage$ cd /opt/sage-2.10/ sage$ make
Time for triple coffee...
To maintain the installation and install optional packages:
sage$ export http_proxy=http://proxy....:8080 sage$ ./sage -upgrade sage$ ./sage -optional sage$ ./sage -i extra_docs- sage$ ./sage -i openssl-0.9.8d.p1 sage$ ./sage -i pyopenssl-0.6 sage$ ./sage -i gap_packages-4.4.10_3 sage$ ./sage -i database_gap-4.4.10 ...
Create an account to run sage as webserver
# adduser --disabled-password --shell /bin/false saged # cp /opt/sage-2.10/sage /home/install
Edit the launch script /home/install/sage to point to the right directory:
SAGE_ROOT="/opt/sage-2.10" # ln -s /home/install/sage /usr/local/bin
To start & stop the webserver as a real daemon, in a screen session, save the following script as /home/install/saged:
#! /bin/sh # Author: Philippe Teuwen # Do NOT "set -e" PATH=/usr/sbin:/usr/bin:/sbin:/bin DESC="Launching SAGE webserver" NAME=sage PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME DAEMON=/usr/local/bin/sage HOST="fqdn.of.the.server" PORT="8000" ARGS="-c \"notebook(address=\\\"$HOST\\\",port=$PORT,accounts=true)\"" USER=saged # Exit if mysql client is not installed [ -x "$DAEMON" ] || exit 0 # Load the VERBOSE setting and other rcS variables [ -f /etc/default/rcS ] && . /etc/default/rcS # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { if [ -e $PIDFILE ]; then if ps -p $(cat $PIDFILE) >/dev/null; then echo -n -e "\nError: $NAME seems to be already running!" return 1 else rm -f $PIDFILE fi fi screen -d -m -S sage su -s /bin/bash - $USER -c "$DAEMON $ARGS" sleep 1 # PID of screen PID=$(screen -ls sage|grep sage|sed 's/[[:space:]]*\([0-9]\+\)\..*/\1/') # PID of su PID=$(ps --ppid $PID -o pid --no-headers) # PID of sage PID=$(ps --ppid $PID -o pid --no-headers) echo $PID > $PIDFILE } # # Function that stops the daemon/service # do_stop() { if [ -e $PIDFILE ]; then PID=$(cat $PIDFILE) if ps -p $PID > /dev/null; then # kill script kill $PID rm -f $PIDFILE return 0 else echo -e "\nWarning: $NAME was not running." echo -n -e "\nCleaning PID file" rm -f $PIDFILE return 1 fi else echo -n -e "\nWarning: $NAME was not running" return 1 fi } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart|force-reload) # # If the "reload" option is implemented then remove the # 'force-reload' alias # log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac :
If you don want anybody to be able to create an account (which gives access to bash!!), remove ",accounts=true" from ARGS.
Install the script:
# ln -s /home/install/saged /etc/init.d # update-rc.d saged defaults 99 01
Upgrade to 2.10.1
I had many troubles because of a caching proxy
A ticket was filled for this issue: http://trac.sagemath.org/sage_trac/ticket/2043
Meanwhile I tried to get around so I copied manually
http://www.sagemath.org/packages/standard/list -> /opt/sage-2.10/spkg/standard http://www.sagemath.org/packages/standard/deps -> /opt/sage-2.10/spkg/standard http://www.sagemath.org/packages/standard/newest_version -> /opt/sage-2.10/spkg/standard http://www.sagemath.org/packages/standard/README -> /opt/sage-2.10/spkg/standard http://www.sagemath.org/packages/install -> /opt/sage-2.10/spkg
then I had to avoid that download happens during sage -upgrade:
/opt/sage-2.10/local/bin/sage-update lines download_file("standard/list") etc
During sage -upgrade the version control system prompted me, I guess for the sage-update script, I simply quitted the changelog editor and it continued.
But now I see that the upgrade of sage_scripts-2.10.1 was not complete.
The solution to ignore local changes is to delete the directory local/bin/.hg and install again the scripts package:
sage -f sage_scripts-2.10.1
I had also to install a zlib headers package because libpng compilation failed using the local zlib headers.
apt-get install zlib1g-dev
A ticket was filled for this issue: http://trac.sagemath.org/sage_trac/ticket/2043
I tested it:
apt-get remove zlib1g-dev cd /opt/sage-2.10/spkg/standard wget http://sage.math.washington.edu/home/mabshoff/SPKG/libpng-1.2.22.p5.spkg sage -i libpng-1.2.22.p5
But still the same error, ongoing...
Install 2.10.3
To upgrade to 2.10.3 I simply took the full sources under /opt/sage-2.10.3, did make
and modified the path in /usr/local/bin/sage
For the optional packages, as most didn't change their version, I transferred them from the old install to /opt/sage-2.10.3/spkg/optional before installing them with sage -i package
Note that this full installation relied on the scripts & setup I installed before, cf the initial installation described at the top of the page.
Install 2.11
To upgrade to 2.11 I simply took the full sources under /opt/sage-2.11, did make
and modified the path in /usr/local/bin/sage
I also ran make test
and that was ok.
But on a second machine I got an error at compile time, g++ killed. That was due to exhaused memory so I stopped the Sage notebook during the compilation of the new version and it went fine.
TODO: transfer the optional packages
Client tuning
jsMath fonts
If you want to install the jsMath fonts locally on your client for a faster rendering:
Download TEX fonts and install them either in ~/.fonts/ or C:\Windows\Fonts
SSH & X11 PortForwarding
SAGE console via ssh
Some notes to give a console access with python autocompletion:
Put ssh keys in /home/saged/.ssh/authorized_keys
Set /usr/local/bin/sage as shell of user saged in /etc/passwd
Then on the client side:
Host sage Hostname blabla User saged
SAGE console via ssh with X11 forwarding
Some notes to enable X11 forwarding with the sage console:
apt-get install xbase-clients vi /etc/ssh/sshd_config X11Forwarding yes #if you're in a vserver: X11UseLocalhost no /etc/init.d/ssh restart
Then on the client side:
Host sage Hostname blabla User saged ForwardX11 yes
Maxima plot via X11
Some notes to enable tcl/tk interactive plotting with maxima:
You need X11 forwarding, cf above
apt-get install tk8.4
Test:
ssh sage Last login: blabla ---------------------------------------------------------------------- | SAGE Version 2.10, Release Date: 2008-01-18 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: maxima.plot2d('cos(2*x) + 2*cos(x)','[x,0,1]','[plot_format,openmath]')
or
sage: maxima.eval('load("plotdf")') sage: maxima.eval('plotdf(x+y,[trajectory_at,2,-0.1]);')
or
sage: maxima.plot3d("sin(x^2+y^2)","[x,-3,3]","[y,-3,3]",'[plot_format,openmath]')
octave & gnuplot via X11
Some notes to enable octave and gnuplot:
You need X11 forwarding, cf above
apt-get install octave gnuplot
Test:
ssh sage Last login: blabla ---------------------------------------------------------------------- | SAGE Version 2.10, Release Date: 2008-01-18 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: octave.de_system_plot(['x+y', 'x-y'], [1, -1], [0,2])
singular & surf via X11
Some notes to enable surf for singular:
You need X11 forwarding, cf above
We need to compile surf from the sources:
apt-get install zlib1g-dev libjpeg62-dev libtiff4-dev flex \ libgmp3-dev libgtk1.2-dev libx11-dev libxmu-headers libxmu-dev cd /opt wget "http://downloads.sourceforge.net/surf/surf-1.0.5.tar.gz" tar xzf surf-1.0.5.tar.gz cd surf-1.0.5/ ./configure make ln -s /opt/surf-1.0.5/surf /usr/local/bin
To run the binary, you don't need all the header packages but you still need some libraries (if you compiled from sources you already have it)
apt-get install libgmp3c2 libgtk1.2
Test:
ssh sage Last login: blabla ---------------------------------------------------------------------- | SAGE Version 2.10, Release Date: 2008-01-18 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: s = singular.eval sage: s('LIB "surf.lib";') '// ** loaded /opt/sage-2.10/local/LIB/surf.lib (1.28,2007/07/13)' sage: s("ring rr0 = 0, (x1,x2),dp;") sage: s("ideal I = x1^3 - x2^2;") sage: s("plot(I);") "Press q to exit from 'surf'"
or
sage: singular.eval('ring rr1 = 0,(x,y,z),dp;') sage: singular.eval('ideal I(1) = 2x2-1/2x3 +1-y+1;') sage: singular.eval('plot(I(1));') "Press q to exit from 'surf'"
Interfaces to proprietary software
Maple
Some notes if you want to use your Maple 32-bit on a 64-bit arch:
apt-get install ia32-libs /bin/maple -binary IBM_INTEL_LINUX
Or from Sage:
maple.fsolve('x^2=cos(x)+4', 'x=0..5')
Maple via X11
You need X11 forwarding, cf above
Test:
ssh sage Last login: blabla ---------------------------------------------------------------------- | SAGE Version 2.10, Release Date: 2008-01-18 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: sh.eval("xmaple")
SAGE & cryptology
Discussions
- http://groups.google.com/group/sage-devel/browse_thread/thread/9557f299b1ec2fab?hl=en
- http://www.informatik.uni-bremen.de/cgi-bin/cgiwrap/malb/blosxom.pl/2008/03/21#sage-crypto-todo
- JSAGE
- for developers
Available
- sage.crypto
- Sage ships PyCrypto
which implements many standard cryptographic algorithms.
It is not really meant for research/education/playing around but for production code but maybe something could be done to have easier access to it from within Sage.
The docstring level documentation is horrible:
sage: import Crypto.Cipher.IDEA sage: Crypto.Cipher.IDEA? x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- book written on Cryptography by David Kohel, using SAGE
- ? openssl & pyopenssl optional packages
Wishes
- General trac
- sage.crypto: block ciphers
- Someone needs to replace FiniteField_ext_pari with the two NTL implementations (they are much faster).
- elliptic and hyperelliptic curves over finite fields support is rather poor
- algebraic aspects received some attention for the cryptanalysis of symmetric cryptographic algorithms, i.e. the cryptanalyst expresses the cipher as a large set of multivariate polynomials and attempts to solve the system. The most common case over GF(2) is handled by PolyBoRi. This library is the backbone of BooleanPolynomialRing and friends. This class needs testing, documentation, extension and bugfixes. Basically someone should sit down and add all the methods of MPolynomial[Ring]_libsingular to BooleanPolynomial[Ring] which make sense, add a ton of doctests and test the hell out of the library to make sure no SIGSEGVs surprise the user.
- the module sage.crypto.mq is also relevant for the above.
- Univariate polynomials over GF(2) are still implemented via NTL's ZZ_pX class rather than GF2X. This should be changed. Also this ticket has a link to gf2x a very small drop in replacement C library which claimed to be 5x faster than NTL. Though, a formal vote is needed to get it into Sage.
- At the end of the day everything boils down to linear algebra. So if you improve that, everybody wins. Sparse linear algebra mod p is still too slow (Ralf-Phillip Weinmann did some work here wrapping code from eclib), there isn o special implementation for sparse linear algebra over GF(2) (both blackbox and e.g. reduced echelon forms), dense LA over GF(2) needs Strassen multiplication/reduction, dense LA over GF(2^n) should probably get implemented.