Skip to content

Exposes API for running Python via JS #182

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

Merged
merged 4 commits into from
Nov 12, 2018

Conversation

rmliddle
Copy link
Contributor

@rmliddle rmliddle commented Oct 28, 2018

Initial steps toward exposing an API for more dynamic executing of python code via JS. This follows a style similar to the: rustwasm-book.
The changes here involve use of wasm-bindgen. This is a possible alternative to the more static complication presented previously:

  1. It may be used to facilitate python execution by javascript, direct type conversion and the like.
  2. Tooling around this method is somewhat more straightfoward

Steps before merging:

  • Work around for console logging (wasm-bindgen captures stdout), prevents println! macro from logging to the browser console
  • Changes to README for wasm compilation + attribution

@rmliddle
Copy link
Contributor Author

@windelbouwman curious what you think about this approach.
Are you more in favour of "static" compilation of RustPython and execution along the lines of a wasm binary or exposing a callable api like this?

@windelbouwman
Copy link
Contributor

@rmliddle I am in favour of having as much options as possible, so if we could go for both approaches someway, then users can pick the solution they require.

@rmliddle
Copy link
Contributor Author

rmliddle commented Nov 2, 2018

I have given this some thought, I think the best way to proceed here is by making a package/module available that wraps wasm_bindgen/web_sys and allows the user to interact with the browser within rustpython.

The only alternative to this might be calling individual python functions from javascript but I don't see that being quite as useful to an end user.

@windelbouwman windelbouwman merged commit 58b905f into RustPython:master Nov 12, 2018
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