Build Python Wheels #15
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 Python Wheels | |
| on: | |
| workflow_dispatch: | |
| env: | |
| BUILD_TYPE: Release | |
| MIN_CIBUILDWHEEL_VERSION: 2.16.2 | |
| PYTHON_VERSION: 3.x | |
| jobs: | |
| build_sdist: | |
| name: Source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| name: Install Python | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install build package | |
| run: python -m pip install build --user | |
| - name: Build sdist | |
| run: python -m build --sdist --outdir dist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| compression-level: 0 # contents are already compressed | |
| build_wheels: | |
| name: ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| matrix: | |
| config: | |
| - { | |
| name: "MacOS Latest (Intel)", | |
| os: macos-latest, | |
| cibw-arch: macosx_x86_64 | |
| } | |
| - { | |
| name: "MacOS Latest (Apple Silicon)", | |
| os: macos-latest, | |
| cibw-arch: macosx_arm64 | |
| } | |
| - { | |
| name: "Ubuntu Latest (x86_64, manylinux)", | |
| os: ubuntu-latest, | |
| cibw-arch: manylinux_x86_64, | |
| } | |
| - { | |
| name: "Ubuntu Latest (ARM64, manylinux)", | |
| os: ubuntu-latest, | |
| cibw-arch: manylinux_aarch64, | |
| use-qemu: true | |
| } | |
| - { | |
| name: "Ubuntu Latest (x86_64, musllinux)", | |
| os: ubuntu-latest, | |
| cibw-arch: musllinux_x86_64 | |
| } | |
| - { | |
| name: "Ubuntu Latest (ARM64, musllinux)", | |
| os: ubuntu-latest, | |
| cibw-arch: musllinux_aarch64, | |
| use-qemu: true | |
| } | |
| - { | |
| name: "Windows Latest", | |
| os: windows-latest, | |
| cibw-arch: win_amd64 | |
| } | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Set up QEMU for linux/arm64 builds | |
| if: runner.os == 'Linux' && matrix.config.use-qemu == true | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| - name: Install Python dependencies | |
| run: python -m pip install cibuildwheel~=${{ env.MIN_CIBUILDWHEEL_VERSION }} | |
| - name: Build wheels | |
| run: python -m cibuildwheel --output-dir dist | |
| env: | |
| CIBW_ENVIRONMENT_MACOS: CMAKE_OSX_ARCHITECTURES=${{ matrix.config.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.config.cibw-arch == 'macosx_arm64' && 'arm64' || '' }} | |
| CIBW_BUILD: "*-${{ matrix.config.cibw-arch }}" | |
| MACOSX_DEPLOYMENT_TARGET: "10.14" # min supporting c++17 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.config.os }}-${{ matrix.config.cibw-arch }} | |
| path: ./dist/*.whl | |
| compression-level: 0 # contents are already compressed | |
| aggregate_artifacts: | |
| name: Aggregate artifacts | |
| runs-on: ubuntu-latest | |
| needs: [build_sdist, build_wheels] | |
| steps: | |
| - name: Merge Artifacts | |
| uses: actions/upload-artifact/merge@v4 | |
| with: | |
| name: python_wheels | |
| compression-level: 0 | |
| delete-merged: true |