Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add readme to WASM example #1703

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/wasm-jupyterlite/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.pixi
*.egg-info
_output
*.doit.db
53 changes: 53 additions & 0 deletions examples/wasm-jupyterlite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# A pixi example to build an emscripten / WASM environment

Read more in [our blog post](https://prefix.dev/blog/pixi_wasm)

Did you know that pixi can handle conda packages that are compiled to WebAssembly? This example shows how to build a simple environment to start & deploy a JupyterLite project with some WASM packages installed.

To deploy to Github pages using `pixi`, you can use the following Github Actions workflow (adapted from the official Jupyterlite demo repo).

You can find a full example (and demo deployment) in [this GitHub repository](https://github.com/wolfv/pixi-wasm) and the [deployed site](https://wolfv.github.io/pixi-wasm/).

```yaml
name: Build and Deploy

on:
push:
branches:
- main
pull_request:
branches:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pixi project
uses: prefix-dev/setup-pixi@v0.8.1
- name: Build dist
run: pixi run build-dist
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
needs: build
if: github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
```
5 changes: 3 additions & 2 deletions examples/wasm-jupyterlite/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ platforms = ["osx-arm64", "osx-64", "linux-64"]

# make sure that we have the WASM environment installed before building the app
[feature.host.tasks]
setup_wasm = { cmd = "pixi install -e wasm", inputs = ["pixi.lock"] }
build-dist = { cmd = "jupyter lite build --output-dir dist --XeusAddon.prefix=.pixi/envs/wasm" }
setup-wasm = { cmd = "pixi install -e wasm", inputs = ["pixi.lock"] }

# build the jupyterlite app
[feature.host.tasks.build]
cmd = "jupyter lite build --XeusAddon.prefix=.pixi/envs/wasm"
depends-on = ["setup_wasm"]
depends-on = ["setup-wasm"]
inputs = ["pixi.lock", "files/"]
outputs = ["_output"]

Expand Down
Loading