You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Full Python-3 environment entirely in Rust (not CPython bindings)
@@ -51,13 +51,13 @@ If you wish to update the online documentation. Push directly to the `release` b
51
51
52
52
-`parser/src`: python lexing, parsing and ast
53
53
-`vm/src`: python virtual machine
54
-
-`builtins.rs`: Builtin functions
55
-
-`compile.rs`: the python compiler from ast to bytecode
56
-
-`obj`: python builtin types
54
+
-`builtins.rs`: Builtin functions
55
+
-`compile.rs`: the python compiler from ast to bytecode
56
+
-`obj`: python builtin types
57
57
-`src`: using the other subcrates to bring rustpython to life.
58
58
-`docs`: documentation (work in progress)
59
59
-`py_code_object`: CPython bytecode to rustpython bytecode convertor (work in progress)
60
-
-`wasm`: Binary crate and resources for WebAssembly build
60
+
-`wasm`: Binary crate and resources for WebAssembly build
61
61
-`tests`: integration test snippets
62
62
63
63
# Contributing
@@ -68,7 +68,7 @@ Most tasks are listed in the [issue tracker](https://github.com/RustPython/RustP
68
68
Check issues labeled with `good first issue` if you wish to start coding.
69
69
70
70
Another approach is to checkout the sourcecode: builtin functions and object methods are often the simplest
71
-
and easiest way to contribute.
71
+
and easiest way to contribute.
72
72
73
73
You can also simply run
74
74
`cargo run tests/snippets/whats_left_to_implement.py` to assist in finding any
@@ -135,44 +135,51 @@ cd emsdk-portable/
135
135
136
136
## Build
137
137
138
-
Move into the `wasm` directory. This contains a custom library crate optimized for wasm build of RustPython.
138
+
Move into the `wasm` directory. This directory contains a library crate for interop
139
+
with python to rust to js and back in `wasm/lib`, the demo website found at
140
+
https://rustpython.github.io/demo in `wasm/demo`, and an example of how to use
141
+
the crate as a library in one's own JS app in `wasm/example`.
139
142
140
-
```bash
143
+
```sh
141
144
cd wasm
142
145
```
143
146
144
-
For testing on a development server, you can run the `build.sh` script. For release build which generates files for deploying to a HTTP server, run `release.sh`.
145
-
146
-
If you don't want to use the above scripts, you can do it manually as follows:
147
+
Go to the demo directory. This is the best way of seeing the changes made to either
148
+
the library or the JS demo, as the `rustpython_wasm` module is set to the global
149
+
JS variable `rp` on the website.
147
150
148
-
Run the build. This can take several minutes depending on the machine.
149
-
150
-
```
151
-
wasm-pack build
151
+
```sh
152
+
cd demo
152
153
```
153
154
154
-
Upon successful build, cd in the the `/pkg` directory and run:
155
+
Now, start the webpack development server. It'll compile the crate and then
156
+
the demo app. This will likely take a long time, both the wasm-pack portion and
157
+
the webpack portion (from after it says "Your crate has been correctly compiled"),
158
+
so be patient.
155
159
160
+
```sh
161
+
npm run dev
156
162
```
157
-
npm link
158
-
```
159
-
160
-
Now move back out into the `/app` directory. The files here have been adapted from [wasm-pack-template](https://github.com/rustwasm/wasm-pack-template).
161
163
162
-
Finally, run:
163
-
164
-
```
165
-
npm install
166
-
npm link rustpython_wasm
164
+
You can now open the webpage on https://localhost:8080 and Python code in either
165
+
the text box or browser devtools with:
166
+
167
+
```js
168
+
rp.pyEval(
169
+
`
170
+
print(js_vars['a'] * 9)
171
+
`,
172
+
{
173
+
vars: {
174
+
a:9
175
+
}
176
+
}
177
+
);
167
178
```
168
179
169
-
and you will be able to run the files with:
170
-
171
-
```
172
-
node_modules/.bin/webpack-dev-server
173
-
```
174
-
175
-
Now open the webpage on https://localhost:8080, you'll be able to run Python code in the text box.
180
+
Alternatively, you can run `npm run build` to build the app once, without watching
181
+
for changes, or `npm run dist` to build the app in release mode, both for the
182
+
crate and webpack.
176
183
177
184
# Code style
178
185
@@ -195,4 +202,3 @@ These are some useful links to related projects:
0 commit comments