From d778201c2aaacb6177d4d5a73fb71f430b738de6 Mon Sep 17 00:00:00 2001 From: David Braley Date: Thu, 13 Jan 2022 18:34:15 -0500 Subject: [PATCH] Force using of `python -m pip` instead of pip if local pip is broken (#43) * Swap virtualenv pip if it's not working * reference correct python versions --- bin/pip | 3 +++ bin/pip2 | 3 +++ shared-functions.sh | 8 ++++++++ 3 files changed, 14 insertions(+) create mode 100755 bin/pip create mode 100755 bin/pip2 diff --git a/bin/pip b/bin/pip new file mode 100755 index 0000000..728728a --- /dev/null +++ b/bin/pip @@ -0,0 +1,3 @@ +#!/bin/bash + +python -m pip $@ \ No newline at end of file diff --git a/bin/pip2 b/bin/pip2 new file mode 100755 index 0000000..b4ca6ba --- /dev/null +++ b/bin/pip2 @@ -0,0 +1,3 @@ +#!/bin/bash + +python2 -m pip $@ \ No newline at end of file diff --git a/shared-functions.sh b/shared-functions.sh index 22fa46b..084ce05 100644 --- a/shared-functions.sh +++ b/shared-functions.sh @@ -164,6 +164,14 @@ create_and_activate_virtualenv() { # Activate the virtualenv. . "$1/bin/activate" + # pip may get broken by virtualenv for some reason. We're better off + # calling `python -m pip` so we'll just swap in a script that does + # that for us. + if ! pip --version 2>/dev/null ; then + cp bin/pip `which pip` + cp bin/pip2 `which pip2` + fi + # pip20+ stopped supporting python2.7, so we need to make sure # we are using an older pip. if ! pip --version | grep -q "pip 1[0-9]"; then