Skip to content

Commit 7c55012

Browse files
authored
Merge pull request #1039 from github/rasmuswl/pip-python2-fix
python-setup: Check if `pip` is already installed for Python2
2 parents 7cf0ed5 + 878b64e commit 7c55012

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

python-setup/install_tools.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ python3 -m pip install --user poetry!=1.0.10
2929
python3 -m pip install --user pipenv
3030

3131
if command -v python2 >/dev/null 2>&1; then
32-
# Setup Python 2 dependency installation tools.
33-
# The Ubuntu 20.04 GHA environment does not come with a Python 2 pip
34-
curl --location --fail https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2
32+
# Setup Python 2 dependency installation tools. The Ubuntu 20.04 GHA environment
33+
# does not come with a Python 2 pip, but if it is already installed, don't try to
34+
# install it again (since that causes problems).
35+
#
36+
# This might seem like a hypothetical situation, but it happens all the time in our
37+
# internal testing where we run the action twice in a row.
38+
if ! python2 -m pip --version; then
39+
echo "Will install pip for python2"
40+
curl --location --fail https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2
41+
fi
3542

3643
python2 -m pip install --user --upgrade pip setuptools wheel
3744

0 commit comments

Comments
 (0)