Skip to content

Commit

Permalink
Scrub multiple ways of describing index-url from requiremnts.txt when…
Browse files Browse the repository at this point in the history
… using vendored installs

See pypa/pip#11276 for the upstream problem.
A fix was already in-place in the python buildback, but it was limited
to a single notation of `index-url=...`
  • Loading branch information
vanschelven committed Jul 20, 2022
1 parent 2d25092 commit d8a8a56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python/supply/supply.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,15 +699,15 @@ func (s *Supplier) RunPipVendored() error {
installArgs = append(installArgs, "--no-build-isolation")
}

// Remove lines from requirements.txt that begin with -i
// Remove lines from requirements.txt that begin with -i, --index-url and --extra-index-url
// because specifying index links here makes pip always want internet access,
// and pipenv generates requirements.txt with -i.
originalReqs, err := ioutil.ReadFile(requirementsPath)
if err != nil {
return fmt.Errorf("could not read requirements.txt: %v", err)
}

re := regexp.MustCompile(`(?m)^\s*-i.*$`)
re := regexp.MustCompile(`(?m)^\s*(-i|--index-url|--extra-index-url)\s+(.*)$`)
modifiedReqs := re.ReplaceAll(originalReqs, []byte{})
err = ioutil.WriteFile(requirementsPath, modifiedReqs, 0644)
if err != nil {
Expand Down

0 comments on commit d8a8a56

Please sign in to comment.