Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs #51

Merged
merged 19 commits into from
Feb 6, 2024
Merged

docs #51

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
76 changes: 76 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: docs

on:
workflow_dispatch:
push:
pull_request:


defaults:
run:
shell: bash -l {0}


jobs:

build_pyjs_docs:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
emsdk_ver: ["3.1.45"]

steps:
- uses: actions/checkout@v2

- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1


- name: Install micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-dev.yml
environment-name: pyjs-wasm

- name: build the docs
shell: bash -el {0}
run: |
./build_docs.sh

################################################################
# upload to github pages
################################################################
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: docs/_build/html


deploy:
# only run on main branch
if: github.ref == 'refs/heads/main' && github.repository == 'emscripten-forge/pyjs'

# Add a dependency to the build job
needs: build_pyjs_docs

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: read # to read the Pages artifact
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3 # or specific "vX.X.X" version tag for this action
29 changes: 12 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,35 @@ jobs:
strategy:
fail-fast: false
matrix:
emsdk_ver: ["3.1.27"]
emsdk_ver: ["3.1.45"]

steps:
- uses: actions/checkout@v2

- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1

- name: Install mamba
uses: mamba-org/provision-with-micromamba@main
- name: Install micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-dev.yml
environment-name: pyjs-wasm
micromamba-version: "1.4.1"
environment-name: pyjs-wasm

- name: Install Playwright
run: |
playwright install
- name: Setup emsdk
shell: bash -el {0}
run: |
micromamba activate pyjs-wasm
emsdk install ${{matrix.emsdk_ver}}
./emsdk/setup_emsdk.sh ${{ matrix.emsdk_ver }} $(pwd)/emsdk_install
- name: Build pyjs
run: |
micromamba activate pyjs-wasm
emsdk activate ${{matrix.emsdk_ver}}
source $CONDA_EMSDK_DIR/emsdk_env.sh
source $(pwd)/emsdk_install/emsdk_env.sh
micromamba create -n pyjs-build-wasm \
--platform=emscripten-32 \
--platform=emscripten-wasm32 \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
--yes \
Expand All @@ -62,7 +58,7 @@ jobs:
mkdir build
pushd build
export PREFIX=$MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
Expand All @@ -80,14 +76,13 @@ jobs:

make install

popd

- name: setup env with numpy
run: |
micromamba activate pyjs-wasm
micromamba create -n pyjs-build-wasm \
--platform=emscripten-32 \
--platform=emscripten-wasm32 \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
--yes \
Expand Down Expand Up @@ -126,7 +121,7 @@ jobs:
run: |
micromamba activate pyjs-wasm
micromamba create -n pyjs-build-wasm \
--platform=emscripten-32 \
--platform=emscripten-wasm32 \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
--yes \
Expand All @@ -146,4 +141,4 @@ jobs:
--pyjs-dir $(pwd)/build \
--headless \
--async-main \
--no-cache
--no-cache
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ build_tests/
node_modules
package-lock.json
docs/_build
*.wasm
nxtgm_javascript_runtime.js
130 changes: 130 additions & 0 deletions build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash
set -e

# dir of this script
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
WASM_ENV_NAME=pyjs-wasm-dev
WASM_ENV_PREFIX=$MAMBA_ROOT_PREFIX/envs/$WASM_ENV_NAME
EMSDK_DIR=$THIS_DIR/emsdk_install
EMSDK_VERSION="3.1.45"




if [ ! -d "$EMSDK_DIR" ]; then
echo "Creating emsdk dir $EMSDK_DIR"
$THIS_DIR/emsdk/setup_emsdk.sh $EMSDK_VERSION $EMSDK_DIR
else
echo "Emsdk dir $EMSDK_DIR already exists"
fi

PYJS_PROBE_FILE=$WASM_ENV_PREFIX/lib_js/pyjs/pyjs_runtime_browser.js

if [ ! -d "$WASM_ENV_PREFIX" ]; then
echo "Creating wasm env $WASM_ENV_NAME"
micromamba create -n $WASM_ENV_NAME \
--platform=emscripten-wasm32 \
-c https://repo.mamba.pm/emscripten-forge \
-c https://repo.mamba.pm/conda-forge \
--yes \
python pybind11 nlohmann_json pybind11_json numpy \
bzip2 sqlite zlib libffi exceptiongroup \
xeus xeus-lite xeus-python-shell xeus-javascript xtl

else
echo "Wasm env $WASM_ENV_NAME already exists"
fi




if [ ! -f "$PYJS_PROBE_FILE" ]; then
echo "Building pyjs"

cd $THIS_DIR
source $EMSDK_DIR/emsdk_env.sh

mkdir -p build
cd build

export PREFIX=$WASM_ENV_PREFIX
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX

emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DBUILD_RUNTIME_BROWSER=ON \
-DBUILD_RUNTIME_NODE=OFF \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
..

emmake make -j2
emmake make install

else
echo "Skipping build pyjs"
fi

# if there is no xeus-python dir, clone it
if [ ! -d "$THIS_DIR/xeus-python" ]; then
cd $THIS_DIR
git clone https://github.com/jupyter-xeus/xeus-python/
else
echo "xeus-python dir already exists"
fi


PYJS_PROBE_FILE=$WASM_ENV_PREFIX/share/jupyter/kernels/xpython/kernel.json
if [ ! -f "$PYJS_PROBE_FILE" ]; then
echo "Building xeus-python"

cd $THIS_DIR
source $EMSDK_DIR/emsdk_env.sh


cd xeus-python

export PREFIX=$WASM_ENV_PREFIX
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX


# remove the fake python
rm -rf $PREFIX/bin/python*
rm -rf $PREFIX/bin/pip*
mkdir -p build_wasm
cd build_wasm


emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DXPYT_EMSCRIPTEN_WASM_BUILD=ON\


emmake make -j8 install

rm -rf $WASM_ENV_PREFIX/share/jupyter/kernels/xpython-raw

else
echo "Skipping build xeus-python"
fi



if true ; then

export PREFIX=$MAMBA_ROOT_PREFIX/envs/pyjs-wasm
echo "Building docs"

cd $THIS_DIR/docs

WASM_ENV_PREFIX=$WASM_ENV_PREFIX LITE=1 make html

# post-build

WASM_ENV_PREFIX=$WASM_ENV_PREFIX python ./post_build.py

fi
7 changes: 5 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
Expand All @@ -14,7 +14,10 @@ help:

.PHONY: help Makefile


# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

$(SPHINXBUILD) -D plot_gallery=1 -b html $(ALLSPHINXOPTS) $(SOURCEDIR) $(BUILDDIR)/html
python post_build.py
11 changes: 0 additions & 11 deletions docs/_src/examples/index.rst

This file was deleted.

16 changes: 0 additions & 16 deletions docs/_src/examples/pyb2d_demo.md

This file was deleted.

11 changes: 0 additions & 11 deletions docs/_src/examples/python_repl_demo.md

This file was deleted.

19 changes: 0 additions & 19 deletions docs/_src/examples/xeus_python.md

This file was deleted.

Loading
Loading