| name: Build Python Packages |
| |
| on: |
| workflow_call: |
| inputs: |
| upload-artifacts: |
| description: "Whether to upload built distributions as artifacts" |
| required: false |
| default: false |
| type: boolean |
| push: |
| branches: ["main"] |
| paths: |
| - 'spatialbench-cli/**' |
| - '.github/workflows/build-py-packages.yml' |
| pull_request: |
| paths: |
| - 'spatialbench-cli/**' |
| - '.github/workflows/build-py-packages.yml' |
| workflow_dispatch: |
| inputs: |
| upload-artifacts: |
| description: "Whether to upload built distributions as artifacts" |
| required: false |
| default: false |
| type: boolean |
| |
| concurrency: |
| group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }} |
| cancel-in-progress: true |
| |
| jobs: |
| wheels: |
| runs-on: ${{ matrix.runner }} |
| strategy: |
| matrix: |
| include: |
| # Linux manylinux |
| - runner: ubuntu-22.04 |
| target: x86_64 |
| manylinux: auto |
| os: linux |
| - runner: ubuntu-22.04 |
| target: x86 |
| manylinux: auto |
| os: linux |
| - runner: ubuntu-22.04 |
| target: aarch64 |
| manylinux: auto |
| os: linux |
| - runner: ubuntu-22.04 |
| target: armv7 |
| manylinux: auto |
| os: linux |
| - runner: ubuntu-22.04 |
| target: ppc64le |
| manylinux: auto |
| os: linux |
| |
| # Linux musllinux |
| - runner: ubuntu-22.04 |
| target: x86_64 |
| manylinux: musllinux_1_2 |
| os: musllinux |
| - runner: ubuntu-22.04 |
| target: x86 |
| manylinux: musllinux_1_2 |
| os: musllinux |
| - runner: ubuntu-22.04 |
| target: aarch64 |
| manylinux: musllinux_1_2 |
| os: musllinux |
| - runner: ubuntu-22.04 |
| target: armv7 |
| manylinux: musllinux_1_2 |
| os: musllinux |
| |
| # Windows |
| - runner: windows-latest |
| target: x64 |
| os: windows |
| - runner: windows-latest |
| target: x86 |
| os: windows |
| |
| # macOS |
| - runner: macos-14 |
| target: x86_64 |
| os: macos |
| - runner: macos-14 |
| target: aarch64 |
| os: macos |
| |
| steps: |
| - uses: actions/checkout@v7 |
| - name: Set ARM architecture flags for Linux cross-compilation |
| if: (matrix.target == 'aarch64' || matrix.target == 'armv7') && (matrix.os == 'linux' || matrix.os == 'musllinux') |
| run: | |
| if [ "${{ matrix.target }}" = "aarch64" ]; then |
| echo "CFLAGS_aarch64_unknown_linux_gnu=-D__ARM_ARCH=8" >> $GITHUB_ENV |
| echo "CFLAGS_aarch64_unknown_linux_musl=-D__ARM_ARCH=8" >> $GITHUB_ENV |
| elif [ "${{ matrix.target }}" = "armv7" ]; then |
| echo "CFLAGS_armv7_unknown_linux_gnueabihf=-D__ARM_ARCH=7" >> $GITHUB_ENV |
| echo "CFLAGS_armv7_unknown_linux_musleabihf=-D__ARM_ARCH=7" >> $GITHUB_ENV |
| fi |
| - name: Build wheels |
| uses: PyO3/maturin-action@v1 |
| with: |
| target: ${{ matrix.target }} |
| args: --release --out dist |
| working-directory: spatialbench-cli |
| manylinux: ${{ matrix.manylinux || '' }} |
| - name: Upload wheels |
| if: ${{ inputs.upload-artifacts || github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} |
| uses: actions/upload-artifact@v7 |
| with: |
| name: wheels-${{ matrix.os }}-${{ matrix.target }} |
| path: spatialbench-cli/dist |
| |
| sdist: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v7 |
| - name: Build sdist |
| uses: PyO3/maturin-action@v1 |
| with: |
| command: sdist |
| args: --out dist |
| working-directory: spatialbench-cli |
| - name: Upload sdist |
| if: ${{ inputs.upload-artifacts || github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} |
| uses: actions/upload-artifact@v7 |
| with: |
| name: wheels-sdist |
| path: spatialbench-cli/dist |