Merge "Fix tox environemnt setup when missing binary packages"

This commit is contained in:
Zuul 2020-03-17 20:34:03 +00:00 committed by Gerrit Code Review
commit b1a67092a5
1 changed files with 16 additions and 12 deletions

View File

@ -6,15 +6,15 @@ source $(dirname "$0")/activate
export PYTHON_VERSION=${PYTHON_VERSION:-} export PYTHON_VERSION=${PYTHON_VERSION:-}
TOX_BASE_PYTHON=${PYTHON:-${CI_TOOLS_DIR}/python} export TOX_BASE_PYTHON=${TOX_BASE_PYTHON:-${CI_TOOLS_DIR}/python}
TOX_VIRTUAL_ENV=$(realpath "${TOX_VIRTUAL_ENV:-.tox/tox}") export TOX_VIRTUAL_ENV=$(realpath "${TOX_VIRTUAL_ENV:-.tox/tox}")
BINDEP=${BINDEP:-} BINDEP=${BINDEP:-}
BINDEP_FILE=${BINDEP_FILE:-$(pwd)/bindep.txt} BINDEP_FILE=${BINDEP_FILE:-$(pwd)/bindep.txt}
function tox { function tox {
tox_setup tox_setup 1>&2
"${TOX_VIRTUAL_ENV}/bin/tox" "$@" "${TOX_VIRTUAL_ENV}/bin/tox" "$@"
} }
@ -39,19 +39,25 @@ function tox_setup {
"${TOX_BASE_PYTHON}" -m virtualenv --seeder pip "${TOX_VIRTUAL_ENV}" "${TOX_BASE_PYTHON}" -m virtualenv --seeder pip "${TOX_VIRTUAL_ENV}"
# Activate virtualenv # Activate virtualenv
if tox_activate; then tox_activate
# Install/upgrade the last Python packages into the new virutalenv
curl https://bootstrap.pypa.io/get-pip.py | tox_python
tox_pip install --upgrade setuptools wheel virtualenv tox
fi
# Install binary packages
tox_install_bindeps
# Install/upgrade the last Python packages into the new virutalenv
curl https://bootstrap.pypa.io/get-pip.py | tox_python
tox_pip install --upgrade setuptools wheel virtualenv tox
fi fi
} }
function tox_install_deps { function tox_install_deps {
tox_install_pip tox_install_pip
"${TOX_BASE_PYTHON}" -m pip install --user --upgrade virtualenv local options="--upgrade"
if [ "${VIRTUAL_ENV:-}" == "" ]; then
options="${options} --user"
fi
"${TOX_BASE_PYTHON}" -m pip install ${options} virtualenv
} }
@ -80,8 +86,6 @@ function tox_activate {
source "${venv_script}" source "${venv_script}"
set -eu set -eu
tox_is_active tox_is_active
tox_install_bindeps
fi fi
} }
@ -101,7 +105,7 @@ function tox_install_bindeps {
local missing_packages=( $(bindep -b -f "${bindep_file}") ) local missing_packages=( $(bindep -b -f "${bindep_file}") )
if [ "${#missing_packages[@]}" != "0" ]; then if [ "${#missing_packages[@]}" != "0" ]; then
tox_install_packages "${missing_packages[@]}" tox_install_packages "${missing_packages[@]}"
bindep -f "${bindep_file}" bindep -f "${bindep_file}" || true
fi fi
} }