#!/bin/sh -e
# Check that the package installs

# Always clean up
trap 'rm -rf check_install_dist check_install_venv' EXIT

# Build the distribution, in a separate directory
rm -rf check_install_dist
python setup.py sdist -d check_install_dist

# Save Python version
PYTHON=$(which python)

# Prepare a clean virtual environment
deactivate >/dev/null 2>&1 || true
rm -rf check_install_venv
virtualenv -p $PYTHON check_install_venv
. check_install_venv/bin/activate

# Install old Django if using Python 2
if python --version 2>&1 | grep -q "Python 2"; then pip install Django==1.*; fi

# Install the package
pip install check_install_dist/*.tar.gz

# Smoke test
python << EOF
import aloe_webdriver.webdriver
EOF
