Skip to content
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
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,21 @@ load_pyodide_pattern = re.compile(
r"\(await ([A-Za-z_$][\w$]*|__webpack_require__)\(476\)\(([A-Za-z_$][\w$]*)\)\)\.loadPyodide"
)
patched_files = []
worker_type_patched_files = []
for path in kernel_extension_dir.glob("*.js"):
source = path.read_text()
patched = load_pyodide_pattern.sub(r"(await import(\2)).loadPyodide", source)
patched = patched.replace("{type:void 0}", '{type:"module"}')
if patched != source:
path.write_text(patched)
patched_files.append(path.name)
if "{type:void 0}" in source and '{type:"module"}' in patched:
worker_type_patched_files.append(path.name)

if not patched_files:
raise SystemExit("No Pyodide dynamic import bundle entry was patched")
if not worker_type_patched_files:
raise SystemExit("No Pyodide worker type entry was patched")
PY
python3 - <<'PY'
import hashlib
Expand Down
2 changes: 1 addition & 1 deletion content-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5401e341378a031ff0d1bc35f51696710a091d23df4fa6592bb2ed4805641c21
757a3beb0900ec3b676d915aaed054bbca25bcd7d7cb6146435ed617adf3d765
9 changes: 9 additions & 0 deletions tests/test_notebooks_pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def test_pyodide_kernel_uses_native_dynamic_import():
assert "(476)(s)).loadPyodide" not in bundle_source


def test_pyodide_kernel_uses_module_workers():
extension_dir = DIST / "extensions" / "@jupyterlite" / "pyodide-kernel-extension" / "static"
js_files = list(extension_dir.glob("*.js"))
assert js_files
bundle_source = "\n".join(path.read_text(encoding="utf8") for path in js_files)
assert '{type:"module"}' in bundle_source
assert "{type:void 0}" not in bundle_source


def _execute_notebook(notebook_path: Path, *, cells: int | None = None, timeout: int = 600) -> None:
"""Execute a notebook using the local CPython kernel.

Expand Down
Loading