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

Commit dc26bbd

Browse files
authored
Merge pull request #10 from martinRenou/xeus-python-build-addon
Xeus python build addon
2 parents 98d28a7 + fe8bed1 commit dc26bbd

12 files changed

+451
-48
lines changed

.github/workflows/build.yml

+130-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
pull_request:
77
branches: '*'
88

9+
defaults:
10+
run:
11+
shell: bash -l {0}
12+
913
jobs:
1014
build:
1115
runs-on: ubuntu-latest
@@ -64,14 +68,14 @@ jobs:
6468
6569
pip install build
6670
python -m build --sdist
67-
cp dist/*.tar.gz myextension.tar.gz
68-
pip uninstall -y myextension jupyterlab
69-
rm -rf myextension
71+
cp dist/*.tar.gz jupyterlite-xeus-python.tar.gz
72+
pip uninstall -y jupyterlite-xeus-python jupyterlab
73+
rm -rf jupyterlite-xeus-python
7074
7175
- uses: actions/upload-artifact@v2
7276
with:
73-
name: myextension-sdist
74-
path: myextension.tar.gz
77+
name: jupyterlite-xeus-python-sdist
78+
path: jupyterlite-xeus-python.tar.gz
7579

7680
test_isolated:
7781
needs: build
@@ -87,16 +91,135 @@ jobs:
8791
architecture: 'x64'
8892
- uses: actions/download-artifact@v2
8993
with:
90-
name: myextension-sdist
94+
name: jupyterlite-xeus-python-sdist
9195
- name: Install and Test
9296
run: |
9397
set -eux
9498
# Remove NodeJS, twice to take care of system and locally installed node versions.
9599
sudo rm -rf $(which node)
96100
sudo rm -rf $(which node)
97-
pip install myextension.tar.gz
101+
pip install jupyterlite-xeus-python.tar.gz
98102
pip install jupyterlab
99103
jupyter labextension list 2>&1 | grep -ie "@jupyterlite/xeus-python-kernel.*OK"
100104
101105
# TODO: add JupyterLite browser check
102106
# python -m jupyterlab.browser_check --no-chrome-test
107+
108+
python-tests-mamba-python:
109+
needs: build
110+
runs-on: ubuntu-latest
111+
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v2
115+
116+
- uses: actions/download-artifact@v2
117+
with:
118+
name: jupyterlite-xeus-python-sdist
119+
120+
- name: Setup conda
121+
uses: conda-incubator/setup-miniconda@v2
122+
with:
123+
activate-environment: xeus-python-kernel
124+
environment-file: environment.yml
125+
python-version: "3.10"
126+
mamba-version: "*"
127+
128+
- name: Make sure the Mamba Python API is available
129+
run: |
130+
mamba install mamba
131+
python -c "from mamba.api import create"
132+
133+
- name: Install
134+
run: |
135+
emsdk install 3.1.2
136+
emsdk activate 3.1.2
137+
pip install jupyterlite-xeus-python.tar.gz
138+
139+
- name: Run tests
140+
run: pytest -rP tests/test_xeus_python_env.py
141+
142+
python-tests-mamba:
143+
needs: build
144+
runs-on: ubuntu-latest
145+
146+
steps:
147+
- name: Checkout
148+
uses: actions/checkout@v2
149+
150+
- uses: actions/download-artifact@v2
151+
with:
152+
name: jupyterlite-xeus-python-sdist
153+
154+
- name: Setup conda
155+
uses: conda-incubator/setup-miniconda@v2
156+
with:
157+
activate-environment: xeus-python-kernel
158+
environment-file: environment.yml
159+
python-version: "3.10"
160+
mamba-version: "*"
161+
162+
- name: Install
163+
run: |
164+
emsdk install 3.1.2
165+
emsdk activate 3.1.2
166+
pip install jupyterlite-xeus-python.tar.gz
167+
168+
- name: Run tests
169+
run: pytest -rP tests/test_xeus_python_env.py
170+
171+
python-tests-micromamba:
172+
needs: build
173+
runs-on: ubuntu-latest
174+
175+
steps:
176+
- name: Checkout
177+
uses: actions/checkout@v2
178+
179+
- uses: actions/download-artifact@v2
180+
with:
181+
name: jupyterlite-xeus-python-sdist
182+
183+
- name: Install mamba
184+
uses: mamba-org/provision-with-micromamba@main
185+
with:
186+
micromamba-version: "0.22.0"
187+
environment-file: environment.yml
188+
environment-name: xeus-python-kernel
189+
190+
- name: Install
191+
run: |
192+
emsdk install 3.1.2
193+
emsdk activate 3.1.2
194+
pip install jupyterlite-xeus-python.tar.gz
195+
196+
- name: Run tests
197+
run: pytest -rP tests/test_xeus_python_env.py
198+
199+
python-tests-conda:
200+
needs: build
201+
runs-on: ubuntu-latest
202+
203+
steps:
204+
- name: Checkout
205+
uses: actions/checkout@v2
206+
207+
- uses: actions/download-artifact@v2
208+
with:
209+
name: jupyterlite-xeus-python-sdist
210+
211+
- name: Setup conda
212+
uses: conda-incubator/setup-miniconda@v2
213+
with:
214+
activate-environment: xeus-python-kernel
215+
environment-file: environment.yml
216+
python-version: "3.10"
217+
218+
- name: Install
219+
run: |
220+
emsdk install 3.1.2
221+
emsdk activate 3.1.2
222+
pip install jupyterlite-xeus-python.tar.gz
223+
224+
- name: Run tests
225+
run: pytest -rP tests/test_xeus_python_env.py

Dockerfile

+11-18
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,39 @@
1-
# TODO Try to combine micromamba and emsdk
2-
# FROM emscripten/emsdk:2.0.32
3-
FROM mambaorg/micromamba:0.22.0
1+
FROM mambaorg/micromamba:0.23.1
42

53
ARG MAMBA_DOCKERFILE_ACTIVATE=1
64
ARG PYTHON_VERSION=3.10
75

8-
RUN micromamba install --yes -c https://repo.mamba.pm/conda-forge \
9-
git pip python=$PYTHON_VERSION click typer
6+
RUN micromamba install --yes -c conda-forge \
7+
git pip python=$PYTHON_VERSION click typer emsdk
108

119
##################################################################
12-
# Install emboa
10+
# Install empack
1311
##################################################################
1412

15-
RUN pip install git+https://github.com/emscripten-forge/emboa
13+
RUN pip install empack
1614

1715
##################################################################
1816
# Setup emsdk
1917
##################################################################
2018

21-
RUN git clone https://github.com/emscripten-core/emsdk.git && \
22-
pushd emsdk && \
23-
./emsdk install 3.1.2 && \
24-
popd
19+
RUN emsdk install 3.1.2 && emsdk activate 3.1.2
2520

2621
##################################################################
2722
# Create emscripten env and pack it
2823
##################################################################
2924

3025
RUN micromamba create -n xeus-python-kernel \
3126
--platform=emscripten-32 \
27+
--root-prefix=/tmp/xeus-python-kernel \
3228
-c https://repo.mamba.pm/emscripten-forge \
3329
-c https://repo.mamba.pm/conda-forge \
3430
--yes \
35-
python=$PYTHON_VERSION xeus-python \
36-
numpy matplotlib
31+
python=$PYTHON_VERSION xeus-python
3732

3833
RUN mkdir -p xeus-python-kernel && cd xeus-python-kernel && \
39-
export FILE_PACKAGER=/tmp/emsdk/upstream/emscripten/tools/file_packager.py && \
40-
/tmp/emsdk/emsdk activate 3.1.2 3.1.2 && \
41-
cp $MAMBA_ROOT_PREFIX/envs/xeus-python-kernel/bin/xpython_wasm.js . && \
42-
cp $MAMBA_ROOT_PREFIX/envs/xeus-python-kernel/bin/xpython_wasm.wasm . && \
43-
emboa pack python core $MAMBA_ROOT_PREFIX/envs/xeus-python-kernel --version=$PYTHON_VERSION
34+
cp /tmp/xeus-python-kernel/envs/xeus-python-kernel/bin/xpython_wasm.js . && \
35+
cp /tmp/xeus-python-kernel/envs/xeus-python-kernel/bin/xpython_wasm.wasm . && \
36+
empack pack python core /tmp/xeus-python-kernel/envs/xeus-python-kernel --version=$PYTHON_VERSION
4437

4538
COPY copy_output.sh .
4639

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
include LICENSE
22
include *.md
3+
include *.yml
34
include pyproject.toml
45
include package.json
56
include install.json
67
include ts*.json
78
include yarn.lock
89
include webpack.config.js
10+
recursive-include tests *.py
911

1012
graft jupyterlite_xeus_python/labextension
1113

environment.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: xeus-python-kernel
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python
6+
- pip
7+
- pytest
8+
- emsdk
9+
- pip:
10+
- jupyterlite
11+
- empack

jupyterlite_xeus_python/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import json
32
from pathlib import Path
43

@@ -11,7 +10,4 @@
1110

1211

1312
def _jupyter_labextension_paths():
14-
return [{
15-
"src": "labextension",
16-
"dest": data["name"]
17-
}]
13+
return [{"src": "labextension", "dest": data["name"]}]

jupyterlite_xeus_python/_version.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
__all__ = ["__version__"]
55

6+
67
def _fetchVersion():
78
HERE = Path(__file__).parent.resolve()
89

@@ -20,4 +21,5 @@ def _fetchVersion():
2021

2122
raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")
2223

24+
2325
__version__ = _fetchVersion()

0 commit comments

Comments
 (0)