#!/bin/bash
set -e

if [ -z "$(which pip)" ]; then
  echo "A local pip installation is required for python development." >&2
  exit 127
fi

if [ -z "$(which virtualenv)" ]; then
    echo "A local virtualenv installation is required for python development." >&2
    exit 127
fi


# setup test fixtures
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"


# clean up any previous fixture venv that might have been created.
if [ "$1" == "-f" ]; then
    echo "removing old fixture setup..."
    git clean -ffX .
fi

# set up a virtualenv and install the packages in the test requirements
virtualenv $BASE_PATH/test/fixtures/pip/venv
. $BASE_PATH/test/fixtures/pip/venv/bin/activate
pip install -r $BASE_PATH/test/fixtures/pip/requirements.txt
deactivate
