Skip to content

Commit

Permalink
pypi package aliases do not need to be a list
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Jan 2, 2024
1 parent 9755ebf commit e6be876
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/backends/python/grab.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func filterImports(ctx context.Context, foundPkgs map[string]bool) (map[string][
}

// test aliases
overrides, ok = moduleToPypiPackageAliases[testModName]
pkg, ok = moduleToPypiPackageAliases[testModName]
if ok {
break
}
Expand Down
8 changes: 4 additions & 4 deletions internal/backends/python/pypi_map.override.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ var moduleToPypiPackageOverride = map[string][]string{
* These are packages that provide helpful aliases, but otherwise provide no functionality.
* We should prefer the real version.
*/
var moduleToPypiPackageAliases = map[string][]string{
"bs4": {"beautifulsoup4"},
"discord": {"discord.py"},
"psycopg2": {"psycopg2-binary"}, // psycopg2 is a source package, psycopg2-binary is the dist wheel
var moduleToPypiPackageAliases = map[string]string{
"bs4": "beautifulsoup4",
"discord": "discord.py",
"psycopg2": "psycopg2-binary", // psycopg2 is a source package, psycopg2-binary is the dist wheel
}
4 changes: 2 additions & 2 deletions internal/backends/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func add(ctx context.Context, pkgs map[api.PkgName]api.PkgSpec, projectName stri
name := string(name)
if found, ok := moduleToPypiPackageAliases[name]; ok {
delete(pkgs, api.PkgName(name))
name = found[0]
name = found
pkgs[api.PkgName(name)] = api.PkgSpec(spec)
}
spec := string(spec)
Expand Down Expand Up @@ -382,7 +382,7 @@ func makePythonPipBackend(python string) api.LanguageBackend {
spec := string(spec)
if found, ok := moduleToPypiPackageAliases[name]; ok {
delete(pkgs, api.PkgName(name))
name = found[0]
name = found
pkgs[api.PkgName(name)] = api.PkgSpec(spec)
}

Expand Down

0 comments on commit e6be876

Please sign in to comment.