22A Python-3 (CPython >= 3.5.0) Interpreter written in Rust :snake : :scream : :metal : .
33
44[ ![ Build Status] ( https://travis-ci.org/RustPython/RustPython.svg?branch=master )] ( https://travis-ci.org/RustPython/RustPython )
5- [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow .svg )] ( https://opensource.org/licenses/MIT )
5+ [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-green .svg )] ( https://opensource.org/licenses/MIT )
66
77# Usage
88
@@ -20,9 +20,6 @@ Or use the interactive shell:
2020 >>>>> 2+2
2121 4
2222
23- <!-- Or use pip to install extra modules:
24-
25- $ cargo run -m pip install requests -->
2623
2724# Goals
2825
@@ -36,15 +33,18 @@ Or use the interactive shell:
3633- ` src ` : using the other subcrates to bring rustpython to life.
3734- ` docs ` : documentation (work in progress)
3835- ` py_code_object ` : CPython bytecode to rustpython bytecode convertor (work in progress)
36+ - ` wasm ` : Binary crate and resources for WebAssembly build
3937- ` tests ` : integration test snippets
4038
4139# Contributing
4240
4341To start contributing, there are a lot of things that need to be done.
4442Most tasks are listed in the [ issue tracker] ( https://github.com/RustPython/RustPython/issues ) .
45- Another approach is to checkout the sourcecode, and try out rustpython until
46- you hit a limitation, and try to fix that. You can also simply run
47- ` cargo run tests/snippets/whats_left_to_implement.py ` and pickup any
43+ Another approach is to checkout the sourcecode: builtin functions and object methods are often the simplest
44+ and easiest way to contribute.
45+
46+ You can also simply run
47+ ` cargo run tests/snippets/todo.py ` to assist in finding any
4848unimplemented method.
4949
5050# Testing
@@ -64,10 +64,62 @@ There also are some unittests, you can run those will cargo:
6464$ cargo test --all
6565```
6666
67+ # Compiling to WebAssembly
68+
69+ ## Setup
70+
71+ Using ` rustup ` add the compile target ` wasm32-unknown-emscripten ` . To do so you will need to have [ rustup] ( https://rustup.rs/ ) installed.
72+
73+ ``` bash
74+ rustup target add wasm32-unknown-emscripten
75+ ```
76+
77+ Next, install ` emsdk ` :
78+
79+ ``` bash
80+ curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | tar -zxv
81+ cd emsdk-portable/
82+ ./emsdk update
83+ ./emsdk install sdk-incoming-64bit
84+ ./emsdk activate sdk-incoming-64bit
85+ source ./emsdk_env.sh
86+ ```
87+
88+ ## Build
89+
90+ Move into the ` wasm ` directory. This contains a custom binary crate optimized for a web assembly build.
91+
92+ ``` bash
93+ cd wasm
94+ ```
95+
96+ From here run the build. This can take several minutes depending on the machine.
97+ ```
98+ cargo build --target=wasm32-unknown-emscripten --release
99+ ```
100+
101+ Upon successful build, the following files will be available:
102+
103+
104+ ```
105+ target/wasm32-unknown-emscripten/release/rustpython_wasm.wasm
106+ target/wasm32-unknown-emscripten/release/rustpython_wasm.js
107+ ```
108+
109+ - ` rustpython_wasm.wasm ` : the wasm build for rustpython. It includes both an parser and virtual machine.
110+ - ` rustpython_wasm.js ` : the loading scripts for the above wasm file.
111+
112+ You will also find ` index.html ` in the ` wasm ` directory.
113+ From here, you can copy these 3 files into the static assets directory of your web server and you should be
114+ able to see the ouput in the web console of your browser.
115+
116+ ```
117+ Hello RustPython!
118+ ```
119+
67120# Code style
68121
69- The code style used is the default rustfmt codestyle. Please format your code
70- accordingly.
122+ The code style used is the default rustfmt codestyle. Please format your code accordingly.
71123
72124# Community
73125
0 commit comments