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

Add Docker build #3

Merged
merged 3 commits into from
May 11, 2022
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
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ dmypy.json
_output
*.doit.db

xeus_python.js
xeus_python.wasm
xeus_python.worker.js
python_data.js
python_data.data
xpython_wasm.js
xpython_wasm.wasm
xeus_python.worker.js
77 changes: 77 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# TODO Try to combine micromamba and emsdk
# FROM emscripten/emsdk:2.0.32
FROM mambaorg/micromamba:0.22.0

ARG MAMBA_DOCKERFILE_ACTIVATE=1

USER root
RUN apt-get update && apt-get install -y cmake
USER $MAMBA_USER

RUN micromamba install --yes -c https://repo.mamba.pm/conda-forge \
git pip python=3.10 click typer

##################################################################
# Install emboa
##################################################################

RUN pip install git+https://github.com/emscripten-forge/emboa

##################################################################
# Setup emsdk
##################################################################

RUN git clone https://github.com/emscripten-core/emsdk.git && \
pushd emsdk && \
./emsdk install 3.1.2 && \
popd

##################################################################
# Create build env
##################################################################

RUN micromamba create -n xeus-python-build-wasm \
--platform=emscripten-32 \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
--yes \
python=3.10 ipython pybind11 jedi xtl nlohmann_json \
pybind11_json numpy xeus "xeus-python-shell>=0.3"

##################################################################
# git config
##################################################################
RUN git config --global advice.detachedHead false

##################################################################
# xeus-python build
##################################################################
# TODO Use a tag that is not master
RUN mkdir -p xeus-python && \
git clone --branch master --depth 1 https://github.com/jupyter-xeus/xeus-python.git xeus-python

RUN mkdir -p xeus-python/build && \
cd xeus-python/build && \
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-python-build-wasm && \
export CMAKE_PREFIX_PATH=$PREFIX && \
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX && \
/tmp/emsdk/emsdk activate 3.1.2 && \
source /tmp/emsdk/emsdk_env.sh && \
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DCMAKE_PROJECT_INCLUDE=cmake/overwriteProp.cmake \
-DXPYT_EMSCRIPTEN_WASM_BUILD=ON \
.. && \
make -j8

RUN cd xeus-python && \
python wasm_patches/patch_it.py

RUN cd xeus-python/build && \
export FILE_PACKAGER=/tmp/emsdk/upstream/emscripten/tools/file_packager.py && \
emboa pack python core $MAMBA_ROOT_PREFIX/envs/xeus-python-build-wasm --version=3.10

COPY copy_output.sh .

ENTRYPOINT ["/bin/bash"]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ The [xeus-python](https://github.com/jupyter-xeus/xeus-python) Python kernel for

![jupyterlite-xeus-python](https://user-images.githubusercontent.com/21197331/167814755-76975633-30f7-4f8e-8fdb-eeec98fa3fd1.gif)


## Requirements

- JupyterLite >= 0.1.0a14
Expand Down
10 changes: 4 additions & 6 deletions build.sh → copy_output.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/bin/bash

set -e


mkdir -p /src/src


cd /xeus-python-build
cp *.{js,wasm} /src/src
cd /tmp/xeus-python/build
ls
cp *python*.{js,wasm,data} /src/src

echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="
echo "============================================="
Loading