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

Commit

Permalink
Try building from the same prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed May 16, 2022
1 parent 563b3e7 commit fa52cf5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ RUN git clone https://github.com/emscripten-core/emsdk.git && \

RUN micromamba create -n xeus-python-kernel \
--platform=emscripten-32 \
--root-prefix=/tmp/xeus-python-kernel \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
--yes \
python=$PYTHON_VERSION xeus-python \
numpy matplotlib
python=$PYTHON_VERSION xeus-python

RUN mkdir -p xeus-python-kernel && cd xeus-python-kernel && \
export FILE_PACKAGER=/tmp/emsdk/upstream/emscripten/tools/file_packager.py && \
/tmp/emsdk/emsdk activate 3.1.2 3.1.2 && \
cp $MAMBA_ROOT_PREFIX/envs/xeus-python-kernel/bin/xpython_wasm.js . && \
cp $MAMBA_ROOT_PREFIX/envs/xeus-python-kernel/bin/xpython_wasm.wasm . && \
emboa pack python core $MAMBA_ROOT_PREFIX/envs/xeus-python-kernel --version=$PYTHON_VERSION
cp /tmp/xeus-python-kernel/envs/xeus-python-kernel/bin/xpython_wasm.js . && \
cp /tmp/xeus-python-kernel/envs/xeus-python-kernel/bin/xpython_wasm.wasm . && \
emboa pack python core /tmp/xeus-python-kernel/envs/xeus-python-kernel --version=$PYTHON_VERSION

COPY copy_output.sh .

Expand Down
24 changes: 15 additions & 9 deletions jupyterlite_xeus_python/env_build_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ def pre_build(self, manager):
return []

self.cwd = TemporaryDirectory()
self.prefix = TemporaryDirectory()

env_name = str(uuid4())
self.prefix = "/tmp/xeus-python-kernel"
self.env_name = "xeus-python-kernel"

# Create emscripten env with the given packages
check_output([
"micromamba",
"create",
"--yes",
"--root-prefix", self.prefix.name,
"--name", env_name,
"--root-prefix", self.prefix,
"--name", self.env_name,
"--platform=emscripten-32",
"-c", "https://repo.mamba.pm/emscripten-forge",
"-c", "https://repo.mamba.pm/conda-forge",
Expand All @@ -83,7 +82,7 @@ def pre_build(self, manager):
# Pack the environment
check_output([
"emboa", "pack", "python", "core",
str(Path(self.prefix.name) / "envs" / env_name),
str(Path(self.prefix) / "envs" / self.env_name),
f"--version={PYTHON_VERSION}"
], cwd=self.cwd.name)

Expand All @@ -102,12 +101,19 @@ def pre_build(self, manager):
for file in ["python_data.js", "python_data.data"]:
yield dict(
name=f"copy:{file}",
actions=[(self.copy_one, [Path(self.cwd.name) / file, dest / file])],
actions=[(self.copy_one, [
Path(self.cwd.name) / file,
dest / file])
],
)

for file in ["xpython_wasm.js", "xpython_wasm.wasm"]:
yield dict(
name=f"copy:{file}",
actions=[(self.copy_one, [Path(self.prefix.name) / "envs" / env_name / "bin" / file, dest / file])],
actions=[(self.copy_one, [
Path(self.prefix) / "envs" / self.env_name / "bin" / file,
dest / file
])],
)

def post_build(self, manager):
Expand All @@ -117,6 +123,6 @@ def post_build(self, manager):
return []

shutil.rmtree(self.cwd.name, ignore_errors=True)
shutil.rmtree(self.prefix.name, ignore_errors=True)
shutil.rmtree(self.prefix, ignore_errors=True)

return []

0 comments on commit fa52cf5

Please sign in to comment.