Skip to content

Commit

Permalink
retry pip upgrade (#35501) (#35659)
Browse files Browse the repository at this point in the history
* use recommended method for upgrading pip

(cherry picked from commit c0de026)

Co-authored-by: Lee E Hinman <57081003+leehinman@users.noreply.github.com>
  • Loading branch information
mergify[bot] and leehinman committed Jun 2, 2023
1 parent f095ee0 commit 073b582
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions dev-tools/mage/pytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package mage

import (
"errors"
"fmt"
"log"
"os"
Expand All @@ -30,7 +31,6 @@ import (

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/pkg/errors"
)

// WINDOWS USERS:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 073b582

Please sign in to comment.