From 8c5b1fef45a85ea9fe45a152acb2f11f43a05046 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Tue, 21 Apr 2020 15:00:49 -0400 Subject: [PATCH] scripts: Add ability to install a different pip version @guits was seeing an issue in ceph-ansible jobs with pip 10.0.0. This commit will allow individual jobs to specify "latest" or "pip==X.X.X" or "pip<20.0.0" as a second parameter to the `install_python_packages` functions. The default behavior is still no second parameter and pip=10.0.0 will still be installed until we're ready to unpin that. Signed-off-by: David Galloway --- scripts/build_utils.sh | 56 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index cddb693b..b1dded49 100644 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -107,10 +107,20 @@ install_python_packages_no_binary () { # the virtualenv exists it will get re-used since this function can be used # along with install_python_packages # - # Usage: + # Usage (with pip 10.0.0 [the default]): # # to_install=( "ansible" "chacractl>=0.0.4" ) # install_python_packages_no_binary "to_install[@]" + # + # Usage (with pip=0.0.4" ) + # install_python_packages_no_binary "to_install[@]" "pip=0.0.4" ) + # install_python_packages_no_binary "to_install[@]" latest create_virtualenv $TEMPVENV @@ -118,7 +128,21 @@ install_python_packages_no_binary () { PIP_SDIST_INDEX="$HOME/.cache/pip" mkdir -p $PIP_SDIST_INDEX - $VENV/pip install "pip==10.0.0" + # We started pinning pip to 10.0.0 as the default to prevent mismatching + # versions on non-ephemeral slaves. Some jobs require different or latest + # pip though so these if statements allow for that. + if [ "$2" == "latest" ]; then + echo "Ensuring latest pip is installed" + $VENV/pip install -U pip + elif [[ -n $2 && "$2" != "latest" ]]; then + echo "Installing $2" + $VENV/pip install "$2" + else + # This is the default for most jobs. + # See ff01d2c5 and fea10f52 + echo "Installing pip 10.0.0" + $VENV/pip install "pip==10.0.0" + fi echo "Updating setuptools" pip_download setuptools @@ -138,10 +162,20 @@ install_python_packages () { # Use this function to create a virtualenv and install # python packages. Pass a list of package names. # - # Usage: + # Usage (with pip 10.0.0 [the default]): # # to_install=( "ansible" "chacractl>=0.0.4" ) # install_python_packages "to_install[@]" + # + # Usage (with pip=0.0.4" ) + # install_python_packages_no_binary "to_install[@]" "pip=0.0.4" ) + # install_python_packages "to_install[@]" latest create_virtualenv $TEMPVENV @@ -149,7 +183,21 @@ install_python_packages () { PIP_SDIST_INDEX="$HOME/.cache/pip" mkdir -p $PIP_SDIST_INDEX - $VENV/pip install "pip==10.0.0" + # We started pinning pip to 10.0.0 as the default to prevent mismatching + # versions on non-ephemeral slaves. Some jobs require different or latest + # pip though so these if statements allow for that. + if [ "$2" == "latest" ]; then + echo "Ensuring latest pip is installed" + $VENV/pip install -U pip + elif [[ -n $2 && "$2" != "latest" ]]; then + echo "Installing $2" + $VENV/pip install "$2" + else + # This is the default for most jobs. + # See ff01d2c5 and fea10f52 + echo "Installing pip 10.0.0" + $VENV/pip install "pip==10.0.0" + fi echo "Updating setuptools" pip_download setuptools -- 2.39.5