From 13a9922d938eee805fb2f0e3d48b83157efdc311 Mon Sep 17 00:00:00 2001 From: Shing Lyu Date: Mon, 10 Dec 2018 21:10:51 +0100 Subject: [PATCH 1/2] Fix the demo page travis build --- .travis.yml | 7 +++---- wasm/release.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c01a4a422..b2b3f97ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,18 +70,19 @@ matrix: if: branch = release env: - REGULAR_TEST=false - - PUBLISH_DOC=true - name: WASM online demo language: rust rust: nightly cache: cargo + install: + - nvm install node + - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh # install wasm-pack script: - cd wasm - bash release.sh if: branch = release env: - REGULAR_TEST=false - - PUBLISH_DEMO=true allow_failures: - rust: nightly env: REGULAR_TEST=true @@ -96,7 +97,6 @@ deploy: keep-history: true on: branch: release - condition: $PUBLISH_DOC = true - provider: pages repo: RustPython/demo target-branch: master @@ -106,4 +106,3 @@ deploy: keep-history: true on: branch: release - condition: $PUBLISH_DEMO = true diff --git a/wasm/release.sh b/wasm/release.sh index bfc4b5fa4..ea5b388c6 100644 --- a/wasm/release.sh +++ b/wasm/release.sh @@ -4,5 +4,5 @@ npm link && \ cd ../app && \ npm install && \ npm link rustpython_wasm && \ -webpack --mode production && \ +node_modules/.bin/webpack --mode production && \ echo "Output saved to app/dist" From 0159051e957e316098ea69e169d32699e2bba1bf Mon Sep 17 00:00:00 2001 From: Shing Lyu Date: Mon, 10 Dec 2018 23:13:54 +0100 Subject: [PATCH 2/2] Updated README about WASM build --- README.md | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7d669aab8..38181dbae 100644 --- a/README.md +++ b/README.md @@ -113,8 +113,7 @@ At this stage RustPython only has preliminary support for web assembly. The inst ## Setup -To get started, install [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/whirlwind-tour/basic-usage.html) -and [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/). You will also need to have `npm` installed. +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) - - ## Build Move into the `wasm` directory. This contains a custom library crate optimized for wasm build of RustPython. @@ -142,7 +139,11 @@ Move into the `wasm` directory. This contains a custom library crate optimized f cd wasm ``` -From here run the build. This can take several minutes depending on the machine. +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`. + +If you don't want to use the above scripts, you can do it manually as follows: + +Run the build. This can take several minutes depending on the machine. ``` wasm-pack build @@ -169,19 +170,7 @@ and you will be able to run the files with: node_modules/.bin/webpack-dev-server ``` -Open a browser console and see the output of rustpython_wasm. To verify this, modify the line in `app/index.js` - -```js -rp.run_code("print('Hello Python!')\n"); -``` - -To the following: - -```js -rp.run_code("assert(False)\n"); -``` - -and you should observe: `Execution failed` in your console output, indicating that the execution of RustPython has failed. +Now open the webpage on https://localhost:8080, you'll be able to run Python code in the text box. # Code style