Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Put back what has been removed
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Feb 9, 2023
1 parent 3d828c7 commit 0f26777
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
39 changes: 19 additions & 20 deletions jupyterlite_xeus_python/build.py
Expand Up @@ -124,8 +124,7 @@ def build_and_pack_emscripten_env(
environment_file: str = "",
root_prefix: str = "/tmp/xeus-python-kernel",
env_name: str = "xeus-python-kernel",
empack_config: str = "",
output_path: str = ".",
empack_config: str = "",https://github.com/martinRenou/xeus-python-kernel
build_worker: bool = False,
force: bool = False,
):
Expand Down Expand Up @@ -220,25 +219,25 @@ def build_and_pack_emscripten_env(
shutil.copyfile(prefix_path / "bin" / file, Path(output_path) / file)

# Copy worker code and process it
# WHEN WOULD WE NOT WANT TO BUILD THE WORKER?
shutil.copytree(
prefix_path / "share" / "xeus-lite",
Path(output_path),
dirs_exist_ok=True,
)
if build_worker:
shutil.copytree(
prefix_path / "share" / "xeus-lite",
Path(output_path),
dirs_exist_ok=True,
)

with open(Path(output_path) / "worker.ts", "r") as fobj:
worker = fobj.read()

worker = worker.replace("XEUS_KERNEL_FILE", "'xpython_wasm.js'")
worker = worker.replace("LANGUAGE_DATA_FILE", "'python_data.js'")
worker = worker.replace("importScripts(DATA_FILE);", """
importScripts(DATA_FILE);
await globalThis.Module.importPackages();
await globalThis.Module.init();
""" )
with open(Path(output_path) / "worker.ts", "w") as fobj:
fobj.write(worker)
with open(Path(output_path) / "worker.ts", "r") as fobj:
worker = fobj.read()

worker = worker.replace("XEUS_KERNEL_FILE", "'xpython_wasm.js'")
worker = worker.replace("LANGUAGE_DATA_FILE", "'python_data.js'")
worker = worker.replace("importScripts(DATA_FILE);", """
importScripts(DATA_FILE);
await globalThis.Module.importPackages();
await globalThis.Module.init();
""" )
with open(Path(output_path) / "worker.ts", "w") as fobj:
fobj.write(worker)

except Exception as e:
raise e
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -62,7 +62,7 @@
"traitlets",
"jupyterlite",
"requests",
"empack>=2.0.5",
"empack>=2.0.6,<3",
"typer",
],
zip_safe=False,
Expand Down

0 comments on commit 0f26777

Please sign in to comment.