From 8a646279fc45fcb9d532079c1b8e054bd2d2ac55 Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Fri, 22 Apr 2022 10:32:29 +0200 Subject: [PATCH] python-setup: Check if `pip` is already installed for Python2 --- python-setup/install_tools.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python-setup/install_tools.sh b/python-setup/install_tools.sh index ede9ac07d..f5014595f 100755 --- a/python-setup/install_tools.sh +++ b/python-setup/install_tools.sh @@ -29,9 +29,16 @@ python3 -m pip install --user poetry!=1.0.10 python3 -m pip install --user pipenv if command -v python2 >/dev/null 2>&1; then - # Setup Python 2 dependency installation tools. - # The Ubuntu 20.04 GHA environment does not come with a Python 2 pip - curl --location --fail https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2 + # Setup Python 2 dependency installation tools. The Ubuntu 20.04 GHA environment + # does not come with a Python 2 pip, but if it is already installed, don't try to + # install it again (since that causes problems). + # + # This might seem like a hypothetical situation, but it happens all the time in our + # internal testing where we run the action twice in a row. + if ! python2 -m pip --version; then + echo "Will install pip for python2" + curl --location --fail https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2 + fi python2 -m pip install --user --upgrade pip setuptools wheel