#!/bin/bash

program=tsgettoolbox

pkgs="\
     setuptools \
     pip \
     pytest \
     coverage \
     flake8 \
     "

envs=`find ~/pythons -maxdepth 1 -mindepth 1 -type d`

pytest_opts='--doctest-modules --ignore docsrc --mpl'

for env in ${envs[@]}; do
    echo "${env}"

    source "${env}"/bin/activate
    pip install --upgrade pip
    pip install wheel
    pip install --no-cache --upgrade --only-binary numpy,pandas,scipy ${pkgs}
    pip uninstall -y ${program}
    rm -rf build
    pip install -e ../${program}
    pytest ${pytest_opts}
    deactivate
done

coverage erase
coverage run `which pytest` ${pytest_opts}
coverage report --include="${program}/*" --omit="tests/*"
coverage html --include="${program}/*" --omit="tests/*"
flake8 ${program}/*.py --exit-zero
