https://github.com/jtpio/jupyterlab-wasm-example
JupyterLab Extension written in Rust and compiled to WebAssembly
https://github.com/jtpio/jupyterlab-wasm-example
jupyterlab jupyterlab-extension rust wasm webassembly
Last synced: over 1 year ago
JSON representation
JupyterLab Extension written in Rust and compiled to WebAssembly
- Host: GitHub
- URL: https://github.com/jtpio/jupyterlab-wasm-example
- Owner: jtpio
- License: bsd-3-clause
- Created: 2020-10-17T22:57:58.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-30T08:16:14.000Z (almost 5 years ago)
- Last Synced: 2025-03-17T13:22:46.891Z (over 1 year ago)
- Topics: jupyterlab, jupyterlab-extension, rust, wasm, webassembly
- Language: Rust
- Homepage:
- Size: 581 KB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jupyterlab-wasm-example

[](https://mybinder.org/v2/gh/jtpio/jupyterlab-wasm-example/main?urlpath=/lab)
Example of a JupyterLab Extension written in Rust and compiled to WebAssembly

## Usage
This repository is meant to be used as an example for extending JupyterLab with WebAssembly modules.
This example uses:
- [Rust](https://rust-lang.org) as the programming language, to implement most of the code for the extension
- [wasm-pack](https://github.com/rustwasm/wasm-pack): build Rust-generated WebAssembly packages and use them from JavaScript
- [JupyterLab](https://github.com/jupyterlab/jupyterlab) build system, to package everything as an extension that can be installed with `pip`
## Requirements
* JupyterLab >= 3.0
## Contributing
### Development install
Note: You will need NodeJS to build the extension package.
The `jlpm` command is JupyterLab's pinned version of
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
`yarn` or `npm` in lieu of `jlpm` below.
```bash
# Clone the repo to your local environment
# Change directory to the jupyterlab-wasm-example directory
# create a new environment
conda create -n jupyterlab-wasm-example -c conda-forge/label/jupyterlab_rc -c conda-forge/label/jupyterlab_server_rc -c conda-forge jupyterlab=3 nodejs python cookiecutter -y
conda activate jupyterlab-wasm-example
# compile the Rust package to WebAssembly:
jlpm run build:rust
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jlpm run install:extension
# Rebuild extension Typescript source after making changes
jlpm run build
```
You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab
```
With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).