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
Copy file name to clipboardExpand all lines: README.md
+12-80
Original file line number
Diff line number
Diff line change
@@ -105,99 +105,31 @@ There also are some unit tests, you can run those with cargo:
105
105
$ cargo test --all
106
106
```
107
107
108
-
# Using another standard library
108
+
# Using a standard library
109
109
110
-
As of now the standard library is under construction.
111
-
112
-
You can play around
113
-
with other standard libraries for python. For example,
114
-
the [ouroboros library](https://github.com/pybee/ouroboros).
110
+
As of now the standard library is under construction. You can
111
+
use a standard library by setting the RUSTPYTHONPATH environment
112
+
variable.
115
113
116
114
To do this, follow this method:
117
115
118
116
```shell
119
-
$ cd~/GIT
120
-
$ git clone git@github.com:pybee/ouroboros.git
121
-
$ export RUSTPYTHONPATH=~/GIT/ouroboros/ouroboros
122
-
$ cd RustPython
123
-
$ cargo run -- -c 'import statistics'
124
-
```
125
-
126
-
# Compiling to WebAssembly
127
-
128
-
At this stage RustPython only has preliminary support for web assembly. The instructions here are intended for developers or those wishing to run a toy example.
129
-
130
-
## Setup
131
-
132
-
To get started, install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) and `npm`. ([wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/whirlwind-tour/basic-usage.html) should be installed by `wasm-pack`. if not, install it yourself)
133
-
134
-
<!-- Using `rustup` add the compile target `wasm32-unknown-emscripten`. To do so you will need to have [rustup](https://rustup.rs/) installed.
135
-
136
-
```bash
137
-
rustup target add wasm32-unknown-emscripten
138
-
```
139
-
140
-
Next, install `emsdk`:
141
-
142
-
```bash
143
-
curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | tar -zxv
144
-
cd emsdk-portable/
145
-
./emsdk update
146
-
./emsdk install sdk-incoming-64bit
147
-
./emsdk activate sdk-incoming-64bit
148
-
``` -->
149
-
150
-
## Build
151
-
152
-
Move into the `wasm` directory. This directory contains a library crate for interop
153
-
with python to rust to js and back in `wasm/lib`, the demo website found at
154
-
https://rustpython.github.io/demo in `wasm/demo`, and an example of how to use
155
-
the crate as a library in one's own JS app in `wasm/example`.
156
-
157
-
```sh
158
-
cd wasm
159
-
```
160
-
161
-
Go to the demo directory. This is the best way of seeing the changes made to either
162
-
the library or the JS demo, as the `rustpython_wasm` module is set to the global
163
-
JS variable `rp` on the website.
164
-
165
-
```sh
166
-
cd demo
117
+
$ export RUSTPYTHONPATH=~/GIT/RustPython/Lib
118
+
$ cargo run -- -c 'import xdrlib'
167
119
```
168
120
169
-
Now, start the webpack development server. It'll compile the crate and then
170
-
the demo app. This will likely take a long time, both the wasm-pack portion and
171
-
the webpack portion (from after it says "Your crate has been correctly compiled"),
172
-
so be patient.
173
-
174
-
```sh
175
-
npm run dev
176
-
```
121
+
You can play around
122
+
with other standard libraries for python. For example,
123
+
the [ouroboros library](https://github.com/pybee/ouroboros).
177
124
178
-
You can now open the webpage on https://localhost:8080 and Python code in either
179
-
the text box or browser devtools with:
180
-
181
-
```js
182
-
rp.pyEval(
183
-
`
184
-
print(js_vars['a'] * 9)
185
-
`,
186
-
{
187
-
vars: {
188
-
a:9
189
-
}
190
-
}
191
-
);
192
-
```
125
+
# Compiling to WebAssembly
193
126
194
-
Alternatively, you can run `npm run build` to build the app once, without watching
195
-
for changes, or `npm run dist` to build the app in release mode, both for the
196
-
crate and webpack.
127
+
[See this doc](wasm/README.md)
197
128
198
129
# Code style
199
130
200
131
The code style used is the default [rustfmt](https://github.com/rust-lang/rustfmt) codestyle. Please format your code accordingly.
132
+
We also use [clippy](https://github.com/rust-lang/rust-clippy) to detect rust code issues.
0 commit comments