# distribute doesn't allow itself to be replaced by setuptools
# so we manually have to delete it
# (pip actually can uninstall setuptools but we may not have pip
# install yet)
rm -rf "$SAGE_LOCAL"/lib/python*/site-packages/setuptools*
rm -rf "$SAGE_LOCAL"/lib/python*/site-packages/distribute*

export PYTHON_EGG_CACHE="$DOT_SAGE/.python-eggs"

cd src

if [ "$SAGE_PYTHON3" = "yes" ]; then
    versions="3"
else
    versions="2 3"
fi

# Prevent setuptools from installing itself with easy_install
for vers in $versions; do
    python${vers} setup.py --no-user-cfg install \
            --single-version-externally-managed --root="$SAGE_DESTDIR" || \
        sdh_die "Error building / installing setuptools for Python ${vers}"
done
