From 073b5824e94527240a23ed23d310a0c85d7f303a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 14:36:48 -0500 Subject: [PATCH] retry pip upgrade (#35501) (#35659) * use recommended method for upgrading pip (cherry picked from commit c0de026cf160f8e9214214e6a511b4a0cf96c191) Co-authored-by: Lee E Hinman <57081003+leehinman@users.noreply.github.com> --- dev-tools/mage/pytest.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dev-tools/mage/pytest.go b/dev-tools/mage/pytest.go index e178778102f..0cf5ae69a6f 100644 --- a/dev-tools/mage/pytest.go +++ b/dev-tools/mage/pytest.go @@ -18,6 +18,7 @@ package mage import ( + "errors" "fmt" "log" "os" @@ -30,7 +31,6 @@ import ( "github.com/magefile/mage/mg" "github.com/magefile/mage/sh" - "github.com/pkg/errors" ) // WINDOWS USERS: @@ -233,16 +233,18 @@ func PythonVirtualenv() (string, error) { "VIRTUAL_ENV": ve, } + vePython := virtualenvPath(ve, pythonExe) + // Ensure we are using the latest pip version. + // use method described at https://pip.pypa.io/en/stable/installation/#upgrading-pip + if err = sh.RunWith(env, vePython, "-m", "pip", "install", "--upgrade", "pip"); err != nil { + fmt.Printf("warn: failed to upgrade pip (ignoring): %v", err) + } + pip := virtualenvPath(ve, "pip") pipUpgrade := func(pkg string) error { return sh.RunWith(env, pip, "install", "-U", pkg) } - // Ensure we are using the latest pip version. - if err = pipUpgrade("pip"); err != nil { - fmt.Printf("warn: failed to upgrade pip (ignoring): %v", err) - } - // First ensure that wheel is installed so that bdists build cleanly. if err = pipUpgrade("wheel"); err != nil { return "", err