#! /usr/bin/env bash
# From sage-spkg.
# For type=script packages, the build rule in build/make/Makefile sources
# sage-env but not sage-dist-helpers.
lib="$SAGE_ROOT/build/bin/sage-dist-helpers"
. "$lib"
if [ $? -ne 0 ]; then
    echo >&2 "Error: failed to source $lib"
    echo >&2 "Is $SAGE_ROOT the correct SAGE_ROOT?"
    exit 1
fi
set -e
# We build the wheel directly with "setup.py bdist_wheel", not with "pip wheel",
# because pip does not handle our symlinks correctly.
(cd src && sdh_setup_bdist_wheel && sdh_store_and_pip_install_wheel .)
# For type=script packages, spkg-check is not run
case "$SAGE_CHECK" in
    yes)
        ./spkg-check
        ;;
    warn)
        ./spkg-check || echo >&2  "Warning: Failures testing package sage_sws2rst (ignored)"
        ;;
esac
