Skip to content

Commit

Permalink
Add package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed May 9, 2022
1 parent cd9505e commit c01f661
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 68 deletions.
33 changes: 8 additions & 25 deletions .github/workflows/main.yml
Expand Up @@ -133,7 +133,7 @@ jobs:
test-wasm:

runs-on: ubuntu
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand All @@ -148,14 +148,10 @@ jobs:

- name: Install mamba
uses: mamba-org/provision-with-micromamba@main

- name: Create micromamba wasm env
run: |
micromamba create -n xeus-python-wasm \
--platform=emscripten-32 --yes \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
pip python ipython pybind11 jedi xtl nlohmann_json pybind11_json numpy xeus xeus-python-shell>=0.3.0
with:
environment-file: environment-dev-wasm.yml
environment-name: xeus-python-wasm
micromamba-version: "0.22.0"

- name: Setup emsdk (TODO Install from conda-forge when available)
run: |
Expand All @@ -176,21 +172,8 @@ jobs:
pushd emsdk
./emsdk activate ${{matrix.emsdk_ver}}
source emsdk_env.sh
export FILE_PACKAGER=$(cwd)/upstream/emscripten/tools/file_packager.py
export FILE_PACKAGER=$(pwd)/upstream/emscripten/tools/file_packager.py
popd
export CMAKE_PREFIX_PATH=$CONDA_PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$CONDA_PREFIX
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release\
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DCMAKE_PROJECT_INCLUDE=overwriteProp.cmake \
-DXPYT_EMSCRIPTEN_WASM_BUILD=ON \
..
make -j ${{ steps.cpu-cores.outputs.count }}
emboa pack python core $CONDA_PREFIX --version=3.10
# TODO Add test with node?
yarn install
yarn run build
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -51,3 +51,6 @@ build/

# Jupyter artefacts
.ipynb_checkpoints/

# JS artifacts
node_modules/
39 changes: 0 additions & 39 deletions build_all.sh

This file was deleted.

32 changes: 32 additions & 0 deletions build_wasm.sh
@@ -0,0 +1,32 @@
#bin/bash
set -e

micromamba create -n xeus-python-kernel --platform=emscripten-32 \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
--yes \
python ipython pybind11 jedi xtl nlohmann_json pybind11_json numpy xeus xeus-python-shell

rm -rf build
mkdir build
cd build

export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-python-kernel
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX

emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DCMAKE_PROJECT_INCLUDE=overwriteProp.cmake \
-DXPYT_EMSCRIPTEN_WASM_BUILD=ON \
..

make -j5

emboa pack python core $MAMBA_ROOT_PREFIX/envs/xeus-python-kernel --version=3.10

cd ..

# patch output
python patch_it.py
9 changes: 9 additions & 0 deletions environment-dev-wasm.yml
@@ -0,0 +1,9 @@
name: xeus-python-wasm
channels:
- conda-forge
dependencies:
- cmake
- pip
- python=3.10
- yarn
- click
34 changes: 34 additions & 0 deletions package.json
@@ -0,0 +1,34 @@
{
"name": "xeus-python",
"version": "0.13.7",
"description": "The xeus-python kernel compiled to WASM",
"keywords": [
"jupyter",
"jupyterlab",
"jupyter-kernel",
"python"
],
"files": [
"build/python_data.js",
"build/python_data.data",
"build/xpython_wasm.js",
"build/xpython_wasm.wasm"
],
"homepage": "https://github.com/jupyter-xeus/xeus-python",
"bugs": {
"url": "https://github.com/jupyter-xeus/xeus-python/issues"
},
"license": "BSD-3-Clause",
"main": "build/xpython_wasm.js",
"repository": {
"type": "git",
"url": "https://github.com/jupyter-xeus/xeus-python"
},
"scripts": {
"build": "yarn run clean && ./build_wasm.sh",
"clean": "rimraf build/"
},
"devDependencies": {
"rimraf": "^2.6.2"
}
}
7 changes: 3 additions & 4 deletions patch_it.py
@@ -1,10 +1,9 @@

with open('./bld_ems/xpython_wasm.js', 'r') as f:
with open('./build/xpython_wasm.js', 'r') as f:
content = f.read()


query = 'Module["preloadPlugins"].push(audioPlugin);'
content = content.replace(query,'')
content = content.replace(query, '')

with open('./bld_ems/xpython_wasm.js', 'w') as f:
with open('./build/xpython_wasm.js', 'w') as f:
f.write(content)
82 changes: 82 additions & 0 deletions yarn.lock
@@ -0,0 +1,82 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"

concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=

glob@^7.1.3:
version "7.2.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"

inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

minimatch@^3.0.4:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=

rimraf@^2.6.2:
version "2.7.1"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==
dependencies:
glob "^7.1.3"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

0 comments on commit c01f661

Please sign in to comment.