Skip to content

Commit

Permalink
Thread through userArgSpec all the way through from the args until we…
Browse files Browse the repository at this point in the history
… write back to reuqirements.txt
  • Loading branch information
blast-hardcheese committed Jan 22, 2024
1 parent 559d6e8 commit 50a4138
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/backends/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ func makePythonPipBackend(python string) api.LanguageBackend {
// compare the package metadata name to the normalized
// pkgs that we are trying to install, to see which we
// want to track in `requirements.txt`.
normalizedPkgs := make(map[api.PkgName]bool)
normalizedPkgs := make(map[api.PkgName]api.PkgName)
for name := range pkgs {
normalizedPkgs[normalizePackageName(name)] = true
normalizedPkgs[normalizePackageName(name)] = name
}

var toAppend []string
Expand All @@ -458,9 +458,13 @@ func makePythonPipBackend(python string) api.LanguageBackend {
matches := matchPackageAndSpec.FindSubmatch(([]byte)(canonicalSpec))
if len(matches) > 0 {
name = normalizePackageName(api.PkgName(string(matches[1])))
}
if normalizedPkgs[name] {
toAppend = append(toAppend, canonicalSpec)
if rawName, ok := normalizedPkgs[name]; ok {
// We've meticulously maintained the pkgspec from the CLI args, if specified,
// so we don't clobber it with pip freeze's output of "==="
name := string(matches[1])
userArgSpec := string(pkgs[rawName])
toAppend = append(toAppend, name+userArgSpec)
}
}
}

Expand Down

0 comments on commit 50a4138

Please sign in to comment.