-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto-installs also have toasts now
- Loading branch information
1 parent
5e4f0c6
commit 3dd1672
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from functools import cache | ||
from sys import modules | ||
|
||
from micropip._compat import REPODATA_PACKAGES | ||
from pyodide.code import find_imports | ||
|
||
|
||
@cache | ||
def build_reversed_index() -> dict[str, str]: | ||
return {import_name: package_name for package_name, info in REPODATA_PACKAGES.items() for import_name in info["imports"]} | ||
|
||
|
||
def import_name_to_package_name(import_name: str): | ||
if import_name not in modules: | ||
return build_reversed_index().get(import_name) | ||
|
||
|
||
def find_packages_to_install(source: str): | ||
return list(filter(None, map(import_name_to_package_name, find_imports(source)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
async def loadPackagesFromImports(source: str): ... # noqa: N802 |