Skip to content

[RFC] Add frozen python Lib to WASM build #1142

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

Closed
palaviv opened this issue Jul 13, 2019 · 3 comments
Closed

[RFC] Add frozen python Lib to WASM build #1142

palaviv opened this issue Jul 13, 2019 · 3 comments
Labels
RFC Request for comments

Comments

@palaviv
Copy link
Contributor

palaviv commented Jul 13, 2019

Summary

In the current WASM build we can import the stdlib libraries written in Rust (time, hashlib for example) but we cannot import any python libs (collections for example). I would suggest to freeze all the modules in the Lib/ folder to allow them to be imported in WASM.

Detailed Explanation

When building the WASM build we will add all the modules in Lib/ to the hashmap in frozen.rs.

Drawbacks, Rationale, and Alternatives

  • This will increase the WASM build size.

Unresolved Questions

  • Should we add libraries like io and os?
  • Should we add this as a feature flag to the regular build?
@palaviv palaviv added the RFC Request for comments label Jul 13, 2019
@windelbouwman
Copy link
Contributor

What we could also do, it extend the pythonpath with an url, and create wasm import hook. So, sys.path will contain https://demo.rustpython.github.io/stdlib, and when we import the logging module, this url is also queried. If a 404 is returned, it means not found, and import resolution continues.

How is this done in brython and skulpt?

@coolreader18
Copy link
Member

The only problem with that is that http requests are asynchronous, so we'd have to have some way of pausing execution of a module and then coming back to it once the promise resolves.

@palaviv
Copy link
Contributor Author

palaviv commented Jul 13, 2019

@windelbouwman I actually thought the same could be done but as @coolreader18 says that will be a problem with the asynchronous requests.
I think that allowing people to import code in the WASM without having to deal with asynchronous requests and promises will be great. I believe we should add the stdlib as default but allowing people to freeze whatever they want into the binary would be a great feature.

This was referenced Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for comments
Projects
None yet
Development

No branches or pull requests

3 participants