Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_imports: only list missing packages #1

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

e-nikolov
Copy link
Contributor

Currently pysandbox tries to micropip.install() all packages from imports even if they are already loaded, e.g.:

  • packages from the standard library like "os"
  • packages loaded previously from another call to micropip.install()
  • relative imports from the filesystem

It works, but there are many errors in the dev console.

This PR changes find_imports() to filter out the existing packages to avoid the errors.

@bugzpodder
Copy link
Owner

Thanks. do you have a preference between pkgutil.iter_modules vs importlib.util.find_spec. I was using the former one.

@e-nikolov
Copy link
Contributor Author

https://docs.python.org/3/library/pkgutil.html mentions that some of the functions in pkgutil were deprecated in Python 3.12 and will be removed in Python 3.14 and to use importlib.util.find_spec(). Not sure about pkgutil.iter_modules specifically.

@bugzpodder bugzpodder merged commit 61a621e into bugzpodder:main Oct 25, 2023
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants