#!/bin/bash
#
# Ensure that each version of Python in the .python_version file is installed
# in pyenv and that tox is installed within each version of Python.
set -euo pipefail

if [ -n "${CI+x}" ]; then exit; fi

pyenv_root=$(pyenv root)

for python_version in 3.10.4 3.9.12 3.8.13; do
    bin_dir=$pyenv_root/versions/$python_version/bin
    if [ ! -f "$bin_dir"/tox ]; then
        pyenv install --skip-existing "$python_version"
        "$bin_dir"/pip install --disable-pip-version-check tox
        pyenv rehash
    fi
done
