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

Obtain wasm packages from emscripten-forge when building deployment #27

Merged
merged 2 commits into from
Oct 7, 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
9 changes: 8 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install the dependencies
run: |
# need the latest JupyterLite 0.4.0 pre-release
python -m pip install --pre jupyterlite-core jupyterlite-pyodide-kernel

# install a dev version of the terminal extension
python -m pip install .

- name: Micromamba needed for cockle_wasm_env
uses: mamba-org/setup-micromamba@main

- name: Build the JupyterLite site
run: |
jupyter lite build --output-dir dist

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ dmypy.json

.jupyterlite.doit.db
_output/
cockle_wasm_env/
cockle-config.json
5 changes: 5 additions & 0 deletions cockle-config-in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"package": "lua"
}
]
41 changes: 41 additions & 0 deletions jupyterlite_terminal/add_on.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""JupyterLite addon to manage obtaining Wasm packages when building deployment"""
import os
from pathlib import Path
import subprocess

from jupyterlite_core.addons.federated_extensions import FederatedExtensionAddon
from jupyterlite_core.constants import (
FEDERATED_EXTENSIONS,
JUPYTERLITE_JSON,
LAB_EXTENSIONS,
SHARE_LABEXTENSIONS,
UTF8,
)


class TerminalAddon(FederatedExtensionAddon):
__all__ = ["post_build"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def post_build(self, manager):
cockleTool = Path("node_modules") / "@jupyterlite" / "cockle" / "lib" / "tools" / "prepare_wasm.js"
assetDir = Path(self.manager.output_dir) / "extensions" / "@jupyterlite" / "terminal" / "static" / "wasm"

# Although cockle's prepare_wasm is perfectly capable of copying the wasm and associated
# files to the asset directory, here we just get the list of required files and let the
# add-on do the copying for consistency with other extensions.
tempFilename = 'cockle-files.txt'
subprocess.run(["node", str(cockleTool), "--list", tempFilename], check=True)

with open(tempFilename, 'r') as f:
for source in f:
source = Path(source.strip())
basename = source.name
yield dict(
name=f"copy:{basename}",
actions=[(self.copy_one, [source, assetDir / basename])],
)

os.remove(tempFilename)
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
"url": "https://github.com/jupyterlite/terminal.git"
},
"scripts": {
"build": "jlpm build:lib && jlpm build:labextension:dev && jlpm build:copywasm",
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension && jlpm build:copywasm",
"build": "jlpm build:lib && jlpm build:labextension:dev",
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc --sourceMap",
"build:lib:prod": "tsc",
"build:copywasm": "cp -r node_modules/@jupyterlite/cockle/lib/wasm jupyterlite_terminal/labextension/static/",
"clean": "jlpm clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
Expand All @@ -62,7 +61,7 @@
"@jupyterlab/services": "^7.2.4",
"@jupyterlab/terminal": "^4.2.4",
"@jupyterlab/terminal-extension": "^4.2.4",
"@jupyterlite/cockle": "^0.0.8",
"@jupyterlite/cockle": "^0.0.9",
"@jupyterlite/contents": "^0.4.0",
"@jupyterlite/server": "^0.4.0",
"@lumino/coreutils": "^2.2.0",
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ dependencies = [
]
dynamic = ["version", "description", "authors", "urls", "keywords"]

[project.entry-points."jupyterlite.addon.v0"]
jupyterlite-terminal = "jupyterlite_terminal.add_on:TerminalAddon"

[tool.hatch.version]
source = "nodejs"

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2808,13 +2808,13 @@ __metadata:
languageName: node
linkType: hard

"@jupyterlite/cockle@npm:^0.0.8":
version: 0.0.8
resolution: "@jupyterlite/cockle@npm:0.0.8"
"@jupyterlite/cockle@npm:^0.0.9":
version: 0.0.9
resolution: "@jupyterlite/cockle@npm:0.0.9"
dependencies:
"@jupyterlite/contents": ^0.4.1
comlink: ^4.4.1
checksum: 60a24a9b73e48a37725eabe60c88db1d2776e2a9df64857be1240c3e1de637e7eb6da4e96bd109be243b34bae3308d20d3eb65f534476edb1b4a21026238b6ec
checksum: 5456bf2a56ce20de57c08e7238ea4f009d5349a5cc9e180ec8076cfb6db17b9dc34c44d921cf9a18d7697cce865418b848c664acbe2f955cfb0eb27981dad703
languageName: node
linkType: hard

Expand Down Expand Up @@ -2922,7 +2922,7 @@ __metadata:
"@jupyterlab/terminal": ^4.2.4
"@jupyterlab/terminal-extension": ^4.2.4
"@jupyterlab/testutils": ^4.2.4
"@jupyterlite/cockle": ^0.0.8
"@jupyterlite/cockle": ^0.0.9
"@jupyterlite/contents": ^0.4.0
"@jupyterlite/server": ^0.4.0
"@lumino/coreutils": ^2.2.0
Expand Down
Loading