Skip to content

Commit

Permalink
fix(deducer): use package name from dist-info instead of import name
Browse files Browse the repository at this point in the history
The package import name may differ from its actual package name. For instance, `pysqlite3-binary` is the package name, but it is imported as `pysqlite3`. This mismatch can cause the loss of required packages at runtime.
  • Loading branch information
jianzs committed Aug 7, 2024
1 parent e3d17b1 commit bc501ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/selfish-bugs-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@plutolang/pyright-deducer": patch
---

fix(deducer): use package name from dist-info instead of import name

The package import name may differ from its actual package name. For instance, `pysqlite3-binary` is the package name, but it is imported as `pysqlite3`. This mismatch can cause the loss of required packages at runtime.
2 changes: 1 addition & 1 deletion components/deducers/python-pyright/src/import-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function getInstallableModule(module: ImportResult): InstalledModule {
const distInfos = getAllDistInfos(path.dirname(pkgPath));
for (const distInfo of distInfos) {
if (distInfo.topLevel.includes(pkgName)) {
return InstalledModule.create(pkgName, distInfo.version);
return InstalledModule.create(distInfo.name, distInfo.version);
}
}
}
Expand Down

0 comments on commit bc501ed

Please sign in to comment.