Skip to content

Commit

Permalink
docs: move to newest pyodide toolchain (#2062)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Schreiner <henry.fredrick.schreiner@cern.ch>
  • Loading branch information
agoose77 and henryiii committed Jun 22, 2023
1 parent 2e4d3d9 commit efa1168
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 14 deletions.
84 changes: 73 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,65 @@ concurrency:
cancel-in-progress: true

env:
PYTHON_VERSION: "3.10.6"
X86_64_PYTHON_VERSION: "3.10.6"
SOURCE_DATE_EPOCH: "1668811211"

jobs:
pyodide-python-version:
name: Determine Pyodide Python version
runs-on: ubuntu-22.04
outputs:
python-version: ${{ steps.retrieve-python-version.outputs.python-version }}
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Cache python version
id: cache-pyodide-python-version
uses: actions/cache@v3
with:
path: pyodide-python-version
key: ${{ runner.os }}-docs-pyodide-python-version-${{ hashFiles('docs/requirements-wasm.txt') }}

- name: Setup Python
if: steps.cache-pyodide-python-version.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: "${{ env.X86_64_PYTHON_VERSION }}"

- name: Install dependencies
if: steps.cache-pyodide-python-version.outputs.cache-hit != 'true'
run: python3 -m pip install -r docs/requirements-wasm.txt

- name: Determine Python version
if: steps.cache-pyodide-python-version.outputs.cache-hit != 'true'
id: compute-python-version
run: |
# Save Python version
PYTHON_VERSION=$(pyodide config get python_version)
echo $PYTHON_VERSION > pyodide-python-version
- name: Retrieve Python version
id: retrieve-python-version
run: |
PYTHON_VERSION=$(cat pyodide-python-version)
echo "python-version=$PYTHON_VERSION" >> "$GITHUB_OUTPUT"
awkward-cpp-wasm:
name: Build C++ WASM
runs-on: ubuntu-22.04
needs: [pyodide-python-version]
steps:
- uses: actions/checkout@v3
with:
submodules: true


- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "${{ env.PYTHON_VERSION }}"
python-version: "${{ needs.pyodide-python-version.outputs.python-version }}"

- name: Generate build files
run: pipx run nox -s prepare -- --headers --signatures
Expand All @@ -38,21 +81,35 @@ jobs:
uses: actions/cache@v3
with:
path: ./awkward-cpp/dist
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-awkward-cpp-wasm-${{ hashFiles('awkward-cpp/**') }}
key: ${{ runner.os }}-"${{ needs.pyodide-python-version.outputs.python-version }}-awkward-cpp-wasm-${{ hashFiles('awkward-cpp/**') }}

- name: Install dependencies
if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true'
run: python3 -m pip install -r docs/requirements-wasm.txt

- name: Determine EMSDK version
if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true'
id: compute-emsdk-version
run: |
# Prepare xbuild environment (side-effect)
pyodide config list
# Save EMSDK version
EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
echo "emsdk-version=$EMSCRIPTEN_VERSION" >> $GITHUB_OUTPUT
working-directory: awkward-cpp

- name: Install EMSDK
uses: mymindstorm/setup-emsdk@v12
if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true'
with:
version: 3.1.14
version: ${{ steps.compute-emsdk-version.outputs.emsdk-version }}

- name: Build wheel
if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true'
id: build-awkward-cpp-wasm-wheel
run: |
# pyodide-build doesn't work out of the box with pipx
python3 -m pip install pyyaml pyodide-build==0.21.0
export CMAKE_ARGS="-DEMSCRIPTEN=1"
pyodide build --exports whole_archive
CMAKE_ARGS="-DEMSCRIPTEN=1 -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH" pyodide build --exports whole_archive
working-directory: awkward-cpp

- name: Upload wheel
Expand All @@ -64,6 +121,10 @@ jobs:
awkward-cpp-x86-64:
runs-on: ubuntu-22.04
name: Build C++ x86
defaults:
run:
# Ensure conda env is activated
shell: "bash -l {0}"
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -88,8 +149,9 @@ jobs:
cache-downloads: true
environment-file: docs/environment.yml
create-args: >-
python=${{ env.PYTHON_VERSION }}
python=${{ env.X86_64_PYTHON_VERSION }}
doxygen
python-build
- name: Generate build files
run: pipx run nox -s prepare -- --headers --signatures
Expand All @@ -99,11 +161,11 @@ jobs:
uses: actions/cache@v3
with:
path: ./awkward-cpp/dist
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-awkward-x86-64-wasm-${{ hashFiles('awkward-cpp/**') }}
key: ${{ runner.os }}-${{ env.X86_64_PYTHON_VERSION }}-awkward-x86-64-wasm-${{ hashFiles('awkward-cpp/**') }}

- name: Build wheel
if: steps.cache-awkward-cpp-x86-64-wheel.outputs.cache-hit != 'true'
run: pipx run build -w ./awkward-cpp
run: python -m build -w ./awkward-cpp

- name: Upload wheel
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -164,7 +226,7 @@ jobs:
cache-downloads: true
environment-file: docs/environment.yml
create-args: >-
python=${{ env.PYTHON_VERSION }}
python=${{ env.X86_64_PYTHON_VERSION }}
doxygen
- name: Download awkward wheel
Expand Down
1 change: 1 addition & 0 deletions docs/requirements-wasm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyodide-build==0.23.3
9 changes: 6 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# JupyterLite (kernel requires specific pyodide version)
jupyterlite-pyodide-kernel==0.0.8
jupyterlite[piplite]==0.1.0
jupyterlite-sphinx==0.8.0

sphinx>=4.5.0,<5.0.0
PyYAML
black
Expand All @@ -9,12 +14,10 @@ sphinx-sitemap
pydata-sphinx-theme
myst-nb
sphinx-external-toc
jupyterlite-sphinx==0.7.3
ipyleaflet
jupyterlite[piplite]==0.1.0b16

numpy>=1.13.1
numba>=0.50.0
numba>=0.50.0;python_version<"3.11"
pandas>=0.24.0
numexpr
pyarrow>=7.0.0
Expand Down

0 comments on commit efa1168

Please sign in to comment.