From bc501ed62eec44b2a2afe63f7e898311ebc2d4bb Mon Sep 17 00:00:00 2001 From: Jade Zheng Date: Wed, 7 Aug 2024 17:38:58 +0800 Subject: [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. --- .changeset/selfish-bugs-wonder.md | 7 +++++++ components/deducers/python-pyright/src/import-finder.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/selfish-bugs-wonder.md diff --git a/.changeset/selfish-bugs-wonder.md b/.changeset/selfish-bugs-wonder.md new file mode 100644 index 00000000..6fea574a --- /dev/null +++ b/.changeset/selfish-bugs-wonder.md @@ -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. diff --git a/components/deducers/python-pyright/src/import-finder.ts b/components/deducers/python-pyright/src/import-finder.ts index ddca76dc..a1f8a0e1 100644 --- a/components/deducers/python-pyright/src/import-finder.ts +++ b/components/deducers/python-pyright/src/import-finder.ts @@ -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); } } }