Skip to content

Commit

Permalink
update to xeus 5 (#37)
Browse files Browse the repository at this point in the history
* update to xeus 5
  • Loading branch information
DerThorsten authored Jun 4, 2024
1 parent 62a3692 commit 0cc37dc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 278 deletions.
77 changes: 5 additions & 72 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ on:
- cron: '0 2 * * *' # run at 2 AM UTC

jobs:
unix:
generic:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -44,20 +44,15 @@ jobs:
mkdir -p bld
cd bld
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
- name: Build
shell: bash -l {0}
run: |
cd xeus-mylang/bld
make -j8
- name: Install
shell: bash -l {0}
run: |
cd xeus-mylang/bld
make install
cmake --build . --target install --config Release
- name: Test
shell: bash -l {0}
Expand All @@ -66,66 +61,11 @@ jobs:
cd xeus-mylang/test
pytest . --reruns 5
win:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest]

steps:
- uses: actions/checkout@v4

- name: Install micromamba
uses: mamba-org/setup-micromamba@v1
with:
init-shell: >-
powershell
cmd.exe
environment-file: .github/ci_env.yml

- name: Create project with cookiecutter
shell: powershell
run:
cookiecutter . --no-input -f

- name: Create and activate env
shell: powershell
run: |
micromamba create -f xeus-mylang\environment-dev.yml -y --name xeus_cookiecutter_test_env
micromamba activate xeus_cookiecutter_test_env
- name: Configure cmake
shell: cmd /C CALL {0}
run: |
micromamba activate xeus_cookiecutter_test_env
cd xeus-mylang
mkdir -p bld
cd bld
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DXEUS_BUILD_TESTS=ON -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%"
- name: Build and install
shell: cmd /C CALL {0}
run: |
micromamba activate xeus_cookiecutter_test_env
cd xeus-mylang/bld
set CL=/MP
nmake install
- name: Test
shell: cmd /C CALL {0}
run: |
micromamba activate xeus_cookiecutter_test_env
cd xeus-mylang/test
pytest . --reruns 5
emscripten_wasm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
emsdk_ver: ["3.1.45"]
# os: [ubuntu-latest, "macos-latest"]

steps:
- uses: actions/checkout@v4
Expand All @@ -147,18 +87,11 @@ jobs:
shell: bash -l {0}
run: micromamba create -f xeus-mylang/environment-wasm-build.yml -y

- name: Setup emsdk
shell: bash -l {0}
run: |
micromamba activate xeus-mylang-wasm-build
emsdk install ${{ matrix.emsdk_ver }}
- name: Build
shell: bash -l {0}
working-directory: xeus-mylang
run: |
micromamba activate xeus-mylang-wasm-build
emsdk activate ${{ matrix.emsdk_ver }}
source $CONDA_EMSDK_DIR/emsdk_env.sh
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
Expand All @@ -181,7 +114,7 @@ jobs:
push:
needs: [unix, win, emscripten_wasm]
needs: [generic, emscripten_wasm]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
178 changes: 6 additions & 172 deletions {{cookiecutter.github_project_name}}/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:
- cron: '0 2 * * *' # run at 2 AM UTC

jobs:
unix:
generic:
{% raw %}
runs-on: ${{ matrix.os }}
{% endraw %}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
Expand All @@ -38,180 +38,25 @@ jobs:
shell: bash -l {0}
run: |
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
working-directory: build

- name: Build
- name: Build & Install
shell: bash -l {0}
{% raw %}
run: make -j${{ steps.cpu-cores.outputs.count }}
run: cmake --build . --target install --config Release
{% endraw %}
working-directory: build

- name: Install
shell: bash -l {0}
run: make install
working-directory: build


- name: Test
shell: bash -l {0}
run: pytest . --reruns 5
working-directory: test

win:
{% raw %}
runs-on: ${{ matrix.os }}
{% endraw %}
strategy:
fail-fast: false
matrix:
os: [windows-latest]

steps:
- uses: actions/checkout@v4

- name: Install micromamba
uses: mamba-org/setup-micromamba@v1
with:
init-shell: >-
powershell
cmd.exe
environment-file: environment-dev.yml

- name: Make build directory
run: mkdir build

- name: Configure cmake
shell: cmd /C CALL {0}
run: |
cmake .. -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DXEUS_BUILD_TESTS=ON ^
-DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" ^
-DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" ^
-DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%"
working-directory: build

- name: Build and install
shell: cmd /C CALL {0}
run: |
set CL=/MP
nmake install
working-directory: build

- name: Test
shell: cmd /C CALL {0}
run: pytest . --reruns 5
working-directory: test

{% if cookiecutter.with_wasm == "yes" -%}
emscripten_wasm_docker:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
container: ["emscripten/emsdk:latest"]

{% raw %}
container: ${{ matrix.container}}
{% endraw %}
steps:
- uses: actions/checkout@v4

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

- name: Verify emscripten
run: emcc -v

- name: Install xtl
{% raw %}
run: |
mkdir -p /opt/xtl/build
git clone https://github.com/xtensor-stack/xtl.git /opt/xtl/src
cd /opt/xtl/src
git checkout 0.7.2
cd /opt/xtl/build
emcmake cmake ../src/ -DCMAKE_INSTALL_PREFIX=/custom_sysroot
emmake make -j${{ steps.cpu-cores.outputs.count }} install
{% endraw %}

- name: Install nlohmann-json
{% raw %}
run: |
mkdir -p /opt/nlohmannjson/build
git clone https://github.com/nlohmann/json.git /opt/nlohmannjson/src
cd /opt/nlohmannjson/src
git checkout v3.9.0
cd /opt/nlohmannjson/build
emcmake cmake ../src/ -DJSON_BuildTests=OFF -DCMAKE_INSTALL_PREFIX=/custom_sysroot
emmake make -j${{ steps.cpu-cores.outputs.count }} install
{% endraw %}

- name: Install xeus
{% raw %}
run: |
mkdir -p /opt/xeus/build
git clone https://github.com/jupyter-xeus/xeus.git /opt/xeus/src
cd /opt/xeus/src
cd /opt/xeus/build
emcmake cmake ../src \
-DXEUS_EMSCRIPTEN_WASM_BUILD=ON \
-DXEUS_BUILD_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=/custom_sysroot\
-Dxtl_DIR=/custom_sysroot/share/cmake/xtl \
-Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json
emmake make -j${{ steps.cpu-cores.outputs.count }}
emmake make -j${{ steps.cpu-cores.outputs.count }} install
{% endraw %}

- name: Install xeus-lite
{% raw %}
run: |
mkdir -p /opt/xeus-lite/build
git clone https://github.com/jupyter-xeus/xeus-lite.git /opt/xeus-lite/src
cd /opt/xeus-lite/build
emcmake cmake ../src \
-DXEUS_EMSCRIPTEN_WASM_BUILD=ON \
-DCMAKE_INSTALL_PREFIX=/custom_sysroot \
-Dxtl_DIR=custom_sysroot/share/cmake/xtl \
-Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json \
-Dxeus_DIR=/custom_sysroot/lib/cmake/xeus
emmake make -j${{ steps.cpu-cores.outputs.count }}
emmake make -j${{ steps.cpu-cores.outputs.count }} install
{% endraw %}

- name: Make build directory
run: mkdir build

- name: Configure cmake rendered project
shell: bash -l {0}
run: |
emcmake cmake .. \
-D{{cookiecutter.cmake_var_prefix}}_EMSCRIPTEN_WASM_BUILD=ON \
-Dxtl_DIR=/custom_sysroot/share/cmake/xtl \
-Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json \
-Dxeus_DIR=/custom_sysroot/lib/cmake/xeus \
-Dxeus-lite_DIR=/custom_sysroot/lib/cmake/xeus-lite \
-DCMAKE_INSTALL_PREFIX=/custom_sysroot
working-directory: build

- name: Build rendered project
shell: bash -l {0}
{% raw %}
run: emmake make -j${{ steps.cpu-cores.outputs.count }}
{% endraw %}
working-directory: build

- name: Install rendered project
shell: bash -l {0}
run: make install
working-directory: build

emscripten_wasm:

runs-on: ubuntu-latest
Expand All @@ -233,20 +78,9 @@ jobs:
environment-file: environment-wasm-build.yml
environment-name: {{cookiecutter.conda_package_name}}-wasm-build

- name: Setup emsdk
shell: bash -l {0}
run: |
{% raw %}
emsdk install ${{ matrix.emsdk_ver }}
{% endraw %}
- name: Build
shell: bash -l {0}
run: |
{% raw %}
emsdk activate ${{ matrix.emsdk_ver }}
{% endraw %}
source $CONDA_EMSDK_DIR/emsdk_env.sh
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
mkdir build
Expand Down
13 changes: 4 additions & 9 deletions {{cookiecutter.github_project_name}}/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,10 @@ endif()
# Dependencies
# ============

set(xtl_REQUIRED_VERSION 0.7.0)
set(xeus_REQUIRED_VERSION 3.0.5)

if (NOT TARGET xtl)
find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED)
endif ()
if (NOT TARGET xeus AND NOT TARGET xeus-static)
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
endif ()
set(xeus_REQUIRED_VERSION 5.0.0)

find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)

# Flags
# =====
Expand Down Expand Up @@ -228,7 +223,7 @@ macro({{cookiecutter.cmake_var_prefix|lower}}_create_target target_name linkage
set({{cookiecutter.cmake_var_prefix}}_XEUS_TARGET xeus-static)
endif ()

target_link_libraries(${target_name} PUBLIC {{'${'}}{{cookiecutter.cmake_var_prefix}}_XEUS_TARGET} xtl)
target_link_libraries(${target_name} PUBLIC {{'${'}}{{cookiecutter.cmake_var_prefix}}_XEUS_TARGET})
if (WIN32 OR CYGWIN)
#
elseif (APPLE)
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.github_project_name}}/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ dependencies:
- cmake
- cxx-compiler
# Host dependencies
- xeus-zmq >=1.0.2,<2.0
- xeus-zmq >=3.0.0,<4.0
- nlohmann_json
- cppzmq
- xtl
# Test dependencies
- pytest
- jupyter_kernel_test>=0.4.3
- nbval
- pytest-rerunfailures
- micromamba
Loading

0 comments on commit 0cc37dc

Please sign in to comment.