CI: extend the usage of cibuildwheel and install the built wheels #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Build | |
| on: [push, pull_request] | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v3.0.1 | |
| env: | |
| SPIRIT_ADD_VERSION_SUFFIX: ${{ github.ref != 'refs/heads/master' }} | |
| CIBW_BUILD: > | |
| cp311-* | |
| cp312-* | |
| CIBW_SKIP: > | |
| pp* | |
| *musllinux* | |
| *-win32 | |
| *_i686 | |
| CIBW_BEFORE_BUILD: > | |
| python -m pip install --upgrade pip | |
| && pip install numpy | |
| && cmake -B build -S . | |
| -DPython3_FIND_STRATEGY=LOCATION | |
| -DCMAKE_BUILD_TYPE=Release | |
| -DSPIRIT_BUILD_FOR_PYTHON=ON | |
| -DSPIRIT_BUILD_TEST=ON | |
| -DSPIRIT_UI_CXX_USE_QT=OFF | |
| -DSPIRIT_UI_IMGUI=OFF | |
| && cmake --build build --config Release -j2 | |
| && ctest -C Release --test-dir build --output-on-failure | |
| && echo "Add version suffix: $SPIRIT_ADD_VERSION_SUFFIX" | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | |
| with: | |
| package-dir: ./core/python | |
| output-dir: wheelhouse | |
| config-file: "{package}/pyproject.toml" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: cibw-wheels-${{ matrix.os }} | |
| path: ./wheelhouse/*.whl | |
| install_wheels: | |
| name: Install wheels on ${{ matrix.os }} (python-${{ matrix.python }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: build_wheels | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python: ["3.11", "3.12"] | |
| steps: | |
| - name: Set up Python ${{ matrix.python }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Download built wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cibw-wheels-${{ matrix.os }} | |
| path: wheelhouse | |
| - name: Install wheel in a clean env | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install wheelhouse/*.whl | |
| - name: Smoke‑test import | |
| shell: bash | |
| run: | | |
| python - <<'EOF' | |
| import spirit | |
| print("Imported version:", spirit.__version__) | |
| from spirit import state | |
| with state.State(quiet=False) as p_state: | |
| pass | |
| EOF |