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

Support use of em-forge wasm files in standalone JupyterLite deployment #31

Merged
merged 1 commit into from
Oct 29, 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ dmypy.json
_output/
cockle_wasm_env/
cockle-config.json
.cockle_temp/
12 changes: 10 additions & 2 deletions jupyterlite_terminal/add_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ 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"
cockleTool = Path("node_modules", "@jupyterlite", "cockle", "lib", "tools", "prepare_wasm.js")
if not cockleTool.is_file():
cockleTool = ".cockle_temp" / cockleTool
cmd = ["npm", "install", "--no-save", "--prefix", cockleTool.parts[0], "@jupyterlite/cockle"]
print("TerminalAddon:", " ".join(cmd))
subprocess.run(cmd, check=True)

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)
cmd = ["node", str(cockleTool), "--list", tempFilename]
print("TerminalAddon:", " ".join(cmd))
subprocess.run(cmd, check=True)

with open(tempFilename, 'r') as f:
for source in f:
Expand Down
Loading