if [ -z "$SAGE_LOCAL" ]; then
    echo "SAGE_LOCAL undefined - exiting..."
    echo "Maybe run 'sage -sh'?"
    exit 1
fi

# Helper functions
success() {
    if [ $? -ne 0 ]; then
        echo "Error building Sphinx: '$1'"
        exit 1
    fi
}

CUR=`pwd`


cd src

# Install new version
echo "Installing Sphinx..."
sdh_pip_install .
success 'Error installing Sphinx'
echo

cd "$CUR"
echo "Creating grammar pickle..."
sage-python23 create_grammar_pickle.py
success 'Error creating the grammar pickle'
echo
