Skip to content

Commit

Permalink
Avoid normalizing pip canonical package name
Browse files Browse the repository at this point in the history
Names in requirements.txt are the package as tracked in package metadata, not necessarily the normalized name of the package.

Example: pip install discord-py will add `discord.py` to the output of `pip freeze`.
  • Loading branch information
blast-hardcheese committed Jan 2, 2024
1 parent 1fb9b79 commit 4ed1ffd
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions internal/backends/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,20 +440,15 @@ func makePythonPipBackend(python string) api.LanguageBackend {
util.RunCmd([]string{"pip", "install", "-r", "requirements.txt"})
},
ListSpecfile: func() map[api.PkgName]api.PkgSpec {
flags, rawPkgs, err := ListRequirementsTxt("requirements.txt")
flags, pkgs, err := ListRequirementsTxt("requirements.txt")
if err != nil {
util.Die("%s", err.Error())
}

normalizedPkgs := make(map[api.PkgName]api.PkgSpec)
for name, spec := range rawPkgs {
normalizedPkgs[normalizePackageName(name)] = spec
}

// Stash the seen flags into a module global
pipFlags = flags

return normalizedPkgs
return pkgs
},
GuessRegexps: pythonGuessRegexps,
Guess: func(ctx context.Context) (map[api.PkgName]bool, bool) { return guess(ctx, python) },
Expand Down

0 comments on commit 4ed1ffd

Please sign in to comment.