cd src

sdh_pip_install .

cd doc
$MAKE html || sdh_die "Error building the documentation"
docdir="$SAGE_LOCAL/share/doc/sagenb"
rm -rf "$docdir"
mv build/html "$docdir"

cd "${SAGE_DESTDIR}"

# SageNB installation path, relative either to / (for real install)
# or to SAGE_DESTDIR.
SAGENB_INSTALL=$(echo ."$SAGE_LOCAL"/lib/python*/site-packages/sagenb)

# Completely remove the old sagenb installation, including bad mathjax
# installations.
( cd / && rm -rf "$SAGENB_INSTALL" )

# Let sagenb use mathjax
ln -s -n "$SAGE_SHARE/mathjax/" "$SAGENB_INSTALL/data/mathjax" || \
    sdh_die "Error: Cannot symlink mathjax into the SageNB data directory."
