#!/usr/bin/env bash

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: '$1'"
        exit 1
    fi
}

CUR=`pwd`

cd src

# Build new version
echo "Building nose..."
python setup.py build
success 'Error building nose'
echo

echo "Removing old version of nose..."
rm -rf "$SAGE_LOCAL"/lib/python/site-packages/Nose-*
success 'Error deleting previous version'
echo

# Install new version
echo "Installing nose..."
python setup.py install
success 'Error installing nose'
echo
