Skip to content

Commit d9eff39

Browse files
authored
Jupyter lite GitHub page (#145)
1 parent edd830f commit d9eff39

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build and Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
jobs:
15+
build:
16+
runs-on: ${{ matrix.os }}
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- name: Github-page
23+
os: ubuntu-24.04
24+
emsdk_ver: "3.1.45"
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: install mamba
31+
uses: mamba-org/setup-micromamba@main
32+
with:
33+
environment-file: environment-wasm-build.yml
34+
init-shell: bash
35+
environment-name: xeus-cpp-wasm-build
36+
37+
- name: Setup default Build Type on *nux
38+
if: ${{ runner.os != 'windows' }}
39+
run: |
40+
os="${{ matrix.os }}"
41+
if [[ "${os}" == "macos"* ]]; then
42+
echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
43+
else
44+
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV
45+
fi
46+
47+
- name: Setup default Build Type on Windows
48+
if: ${{ runner.os == 'windows' }}
49+
run: |
50+
$env:ncpus=$([Environment]::ProcessorCount)
51+
echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV
52+
53+
- name: Setup emsdk
54+
shell: bash -l {0}
55+
run: |
56+
emsdk install ${{matrix.emsdk_ver}}
57+
58+
- name: Build xeus-cpp
59+
shell: bash -l {0}
60+
run: |
61+
emsdk activate ${{matrix.emsdk_ver}}
62+
source $CONDA_EMSDK_DIR/emsdk_env.sh
63+
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
64+
65+
mkdir build
66+
pushd build
67+
68+
export EMPACK_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
69+
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
70+
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
71+
export CMAKE_PREFIX_PATH=$PREFIX
72+
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
73+
74+
emcmake cmake \
75+
-DCMAKE_BUILD_TYPE=Release \
76+
-DCMAKE_PREFIX_PATH=$PREFIX \
77+
-DCMAKE_INSTALL_PREFIX=$PREFIX \
78+
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
79+
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
80+
..
81+
EMCC_CFLAGS='-sERROR_ON_UNDEFINED_SYMBOLS=0' emmake make -j ${{ env.ncpus }} install
82+
83+
- name: Jupyter Lite integration
84+
shell: bash -l {0}
85+
run: |
86+
micromamba create -n xeus-lite-host jupyterlite-core
87+
micromamba activate xeus-lite-host
88+
python -m pip install jupyterlite-xeus
89+
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }} --contents README.md --output-dir dist
90+
91+
- name: Upload artifact
92+
uses: actions/upload-pages-artifact@v3
93+
with:
94+
path: ./dist
95+
96+
deploy:
97+
needs: build
98+
permissions:
99+
pages: write
100+
id-token: write
101+
environment:
102+
name: github-pages
103+
url: ${{ steps.deployment.outputs.page_url }}
104+
runs-on: ubuntu-24.04
105+
steps:
106+
- name: Deploy to GitHub Pages
107+
id: deployment
108+
uses: actions/deploy-pages@v4

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
`xeus-cpp` is a Jupyter kernel for cpp based on the native implementation of the
1515
Jupyter protocol [xeus](https://github.com/jupyter-xeus/xeus).
1616

17+
Try Jupyter Lite demo by clicking below
18+
19+
[![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://compiler-research.github.io/xeus-cpp/lab/index.html)
20+
1721
## Installation within a mamba environment (non wasm build instructions)
1822

1923
To ensure that the installation works, it is preferable to install `xeus-cpp` in a

0 commit comments

Comments
 (0)