|
| 1 | +name: Build wheels |
| 2 | + |
| 3 | +# Reusable wheel-build matrix shared by: |
| 4 | +# - publish.yml (on release: builds the full matrix, then uploads to PyPI) |
| 5 | +# - release-build-check.yml (on PR: build-only smoke of the release path) |
| 6 | +# Keeping the build jobs in ONE place means the pre-merge guard can never |
| 7 | +# drift from what actually publishes. |
| 8 | +on: |
| 9 | + workflow_call: |
| 10 | + inputs: |
| 11 | + linux_only: |
| 12 | + description: "Build only the manylinux Linux wheels (PR-guard mode); skip macOS/Windows/sdist." |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + # Build wheels on Linux using manylinux containers |
| 21 | + build-linux: |
| 22 | + name: Build Linux ${{ matrix.arch }} wheels |
| 23 | + runs-on: ${{ matrix.runner }} |
| 24 | + container: ${{ matrix.container }} |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - arch: x86_64 |
| 29 | + runner: ubuntu-latest |
| 30 | + container: quay.io/pypa/manylinux_2_28_x86_64 |
| 31 | + artifact: wheels-linux-x86_64 |
| 32 | + - arch: aarch64 |
| 33 | + runner: ubuntu-24.04-arm |
| 34 | + container: quay.io/pypa/manylinux_2_28_aarch64 |
| 35 | + artifact: wheels-linux-aarch64 |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v7 |
| 38 | + |
| 39 | + - name: Install system dependencies |
| 40 | + run: dnf install -y openssl-devel perl-IPC-Cmd openblas-devel |
| 41 | + |
| 42 | + - name: Install Rust |
| 43 | + uses: dtolnay/rust-toolchain@stable |
| 44 | + |
| 45 | + - name: Install maturin |
| 46 | + run: /opt/python/cp312-cp312/bin/pip install maturin |
| 47 | + |
| 48 | + - name: Build wheels |
| 49 | + run: | |
| 50 | + expected=0 |
| 51 | + for pyver in 39 310 311 312 313 314; do |
| 52 | + pybin="/opt/python/cp${pyver}-cp${pyver}/bin/python" |
| 53 | + if [ ! -f "$pybin" ]; then |
| 54 | + echo "ERROR: Expected Python interpreter not found: $pybin" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + /opt/python/cp312-cp312/bin/maturin build --release --out dist -i "$pybin" --features extension-module,openblas |
| 58 | + expected=$((expected + 1)) |
| 59 | + done |
| 60 | + actual=$(find dist -maxdepth 1 -name '*.whl' | wc -l) |
| 61 | + echo "Built $actual wheels (expected $expected)" |
| 62 | + if [ "$actual" -ne "$expected" ]; then |
| 63 | + echo "ERROR: Expected $expected wheels but found $actual" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | +
|
| 67 | + - name: Upload wheels |
| 68 | + uses: actions/upload-artifact@v7 |
| 69 | + with: |
| 70 | + name: ${{ matrix.artifact }} |
| 71 | + path: dist/*.whl |
| 72 | + |
| 73 | + # Build wheels on macOS ARM64 (native build) |
| 74 | + # Note: macOS x86_64 skipped - Intel runners retired, users can install from sdist |
| 75 | + build-macos-arm: |
| 76 | + name: Build macOS ARM64 wheels |
| 77 | + if: ${{ !inputs.linux_only }} |
| 78 | + runs-on: macos-14 |
| 79 | + strategy: |
| 80 | + matrix: |
| 81 | + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v7 |
| 84 | + |
| 85 | + - name: Set up Python |
| 86 | + uses: actions/setup-python@v6 |
| 87 | + with: |
| 88 | + python-version: ${{ matrix.python-version }} |
| 89 | + |
| 90 | + - name: Install Rust |
| 91 | + uses: dtolnay/rust-toolchain@stable |
| 92 | + |
| 93 | + - name: Install maturin |
| 94 | + run: pip install maturin |
| 95 | + |
| 96 | + - name: Build wheel |
| 97 | + run: maturin build --release --out dist --features extension-module,accelerate |
| 98 | + |
| 99 | + - name: Upload wheels |
| 100 | + uses: actions/upload-artifact@v7 |
| 101 | + with: |
| 102 | + name: wheels-macos-arm64-py${{ matrix.python-version }} |
| 103 | + path: dist/*.whl |
| 104 | + |
| 105 | + # Build wheels on Windows |
| 106 | + build-windows: |
| 107 | + name: Build Windows wheels |
| 108 | + if: ${{ !inputs.linux_only }} |
| 109 | + runs-on: windows-latest |
| 110 | + strategy: |
| 111 | + matrix: |
| 112 | + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] |
| 113 | + steps: |
| 114 | + - uses: actions/checkout@v7 |
| 115 | + |
| 116 | + - name: Set up Python |
| 117 | + uses: actions/setup-python@v6 |
| 118 | + with: |
| 119 | + python-version: ${{ matrix.python-version }} |
| 120 | + |
| 121 | + - name: Install Rust |
| 122 | + uses: dtolnay/rust-toolchain@stable |
| 123 | + |
| 124 | + - name: Install maturin |
| 125 | + run: pip install maturin |
| 126 | + |
| 127 | + - name: Build wheel |
| 128 | + run: maturin build --release --out dist --features extension-module |
| 129 | + |
| 130 | + - name: Upload wheels |
| 131 | + uses: actions/upload-artifact@v7 |
| 132 | + with: |
| 133 | + name: wheels-windows-py${{ matrix.python-version }} |
| 134 | + path: dist/*.whl |
| 135 | + |
| 136 | + # Build source distribution |
| 137 | + build-sdist: |
| 138 | + name: Build source distribution |
| 139 | + if: ${{ !inputs.linux_only }} |
| 140 | + runs-on: ubuntu-latest |
| 141 | + steps: |
| 142 | + - uses: actions/checkout@v7 |
| 143 | + |
| 144 | + - name: Set up Python |
| 145 | + uses: actions/setup-python@v6 |
| 146 | + with: |
| 147 | + python-version: '3.11' |
| 148 | + |
| 149 | + - name: Install maturin |
| 150 | + run: pip install maturin |
| 151 | + |
| 152 | + - name: Build sdist |
| 153 | + run: maturin sdist --out dist |
| 154 | + |
| 155 | + - name: Upload sdist |
| 156 | + uses: actions/upload-artifact@v7 |
| 157 | + with: |
| 158 | + name: sdist |
| 159 | + path: dist/*.tar.gz |
0 commit comments