|
| 1 | +name: MacOS Python build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} |
| 10 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 11 | + |
| 12 | +env: |
| 13 | + FORCE_COLOR: 1 |
| 14 | + |
| 15 | +jobs: |
| 16 | + pythonbuild: |
| 17 | + runs-on: 'macos-13' |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Emit rustc version |
| 22 | + run: | |
| 23 | + rustc --version > .rustc-version |
| 24 | +
|
| 25 | + - uses: actions/cache@v4 |
| 26 | + with: |
| 27 | + path: | |
| 28 | + ~/.cargo/registry |
| 29 | + ~/.cargo/git |
| 30 | + target |
| 31 | + key: ${{ runner.os }}-pythonbuild-${{ hashFiles('Cargo.lock', '.rustc-version') }} |
| 32 | + |
| 33 | + - name: Build |
| 34 | + run: | |
| 35 | + cargo build --release |
| 36 | +
|
| 37 | + - name: Upload pythonbuild Executable |
| 38 | + uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: pythonbuild |
| 41 | + path: target/release/pythonbuild |
| 42 | + |
| 43 | + build: |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + build: |
| 48 | + - target_triple: 'aarch64-apple-darwin' |
| 49 | + runner: macos-14 |
| 50 | + py: 'cpython-3.9' |
| 51 | + options: 'debug' |
| 52 | + - target_triple: 'aarch64-apple-darwin' |
| 53 | + runner: macos-14 |
| 54 | + py: 'cpython-3.9' |
| 55 | + options: 'pgo' |
| 56 | + - target_triple: 'aarch64-apple-darwin' |
| 57 | + runner: macos-14 |
| 58 | + py: 'cpython-3.9' |
| 59 | + options: 'pgo+lto' |
| 60 | + |
| 61 | + - target_triple: 'aarch64-apple-darwin' |
| 62 | + runner: macos-14 |
| 63 | + py: 'cpython-3.10' |
| 64 | + options: 'debug' |
| 65 | + - target_triple: 'aarch64-apple-darwin' |
| 66 | + runner: macos-14 |
| 67 | + py: 'cpython-3.10' |
| 68 | + options: 'pgo' |
| 69 | + - target_triple: 'aarch64-apple-darwin' |
| 70 | + runner: macos-14 |
| 71 | + py: 'cpython-3.10' |
| 72 | + options: 'pgo+lto' |
| 73 | + |
| 74 | + - target_triple: 'aarch64-apple-darwin' |
| 75 | + runner: macos-14 |
| 76 | + py: 'cpython-3.11' |
| 77 | + options: 'debug' |
| 78 | + - target_triple: 'aarch64-apple-darwin' |
| 79 | + runner: macos-14 |
| 80 | + py: 'cpython-3.11' |
| 81 | + options: 'pgo' |
| 82 | + - target_triple: 'aarch64-apple-darwin' |
| 83 | + runner: macos-14 |
| 84 | + py: 'cpython-3.11' |
| 85 | + options: 'pgo+lto' |
| 86 | + |
| 87 | + - target_triple: 'aarch64-apple-darwin' |
| 88 | + runner: macos-14 |
| 89 | + py: 'cpython-3.12' |
| 90 | + options: 'debug' |
| 91 | + - target_triple: 'aarch64-apple-darwin' |
| 92 | + runner: macos-14 |
| 93 | + py: 'cpython-3.12' |
| 94 | + options: 'pgo' |
| 95 | + - target_triple: 'aarch64-apple-darwin' |
| 96 | + runner: macos-14 |
| 97 | + py: 'cpython-3.12' |
| 98 | + options: 'pgo+lto' |
| 99 | + |
| 100 | + - target_triple: 'aarch64-apple-darwin' |
| 101 | + runner: macos-14 |
| 102 | + py: 'cpython-3.13' |
| 103 | + options: 'debug' |
| 104 | + - target_triple: 'aarch64-apple-darwin' |
| 105 | + runner: macos-14 |
| 106 | + py: 'cpython-3.13' |
| 107 | + options: 'pgo' |
| 108 | + - target_triple: 'aarch64-apple-darwin' |
| 109 | + runner: macos-14 |
| 110 | + py: 'cpython-3.13' |
| 111 | + options: 'pgo+lto' |
| 112 | + |
| 113 | + - target_triple: 'aarch64-apple-darwin' |
| 114 | + runner: macos-14 |
| 115 | + py: 'cpython-3.13' |
| 116 | + options: 'freethreaded+debug' |
| 117 | + - target_triple: 'aarch64-apple-darwin' |
| 118 | + runner: macos-14 |
| 119 | + py: 'cpython-3.13' |
| 120 | + options: 'freethreaded+pgo' |
| 121 | + - target_triple: 'aarch64-apple-darwin' |
| 122 | + runner: macos-14 |
| 123 | + py: 'cpython-3.13' |
| 124 | + options: 'freethreaded+pgo+lto' |
| 125 | + |
| 126 | + # macOS on Intel hardware. This is pretty straightforward. We exclude |
| 127 | + # noopt because it doesn't provide any compelling advantages over PGO |
| 128 | + # or LTO builds. |
| 129 | + - target_triple: 'x86_64-apple-darwin' |
| 130 | + runner: macos-13 |
| 131 | + py: 'cpython-3.9' |
| 132 | + options: 'debug' |
| 133 | + - target_triple: 'x86_64-apple-darwin' |
| 134 | + runner: macos-13 |
| 135 | + py: 'cpython-3.9' |
| 136 | + options: 'pgo' |
| 137 | + - target_triple: 'x86_64-apple-darwin' |
| 138 | + runner: macos-13 |
| 139 | + py: 'cpython-3.9' |
| 140 | + options: 'pgo+lto' |
| 141 | + |
| 142 | + - target_triple: 'x86_64-apple-darwin' |
| 143 | + runner: macos-13 |
| 144 | + py: 'cpython-3.10' |
| 145 | + options: 'debug' |
| 146 | + - target_triple: 'x86_64-apple-darwin' |
| 147 | + runner: macos-13 |
| 148 | + py: 'cpython-3.10' |
| 149 | + options: 'pgo' |
| 150 | + - target_triple: 'x86_64-apple-darwin' |
| 151 | + runner: macos-13 |
| 152 | + py: 'cpython-3.10' |
| 153 | + options: 'pgo+lto' |
| 154 | + |
| 155 | + - target_triple: 'x86_64-apple-darwin' |
| 156 | + runner: macos-13 |
| 157 | + py: 'cpython-3.11' |
| 158 | + options: 'debug' |
| 159 | + - target_triple: 'x86_64-apple-darwin' |
| 160 | + runner: macos-13 |
| 161 | + py: 'cpython-3.11' |
| 162 | + options: 'pgo' |
| 163 | + - target_triple: 'x86_64-apple-darwin' |
| 164 | + runner: macos-13 |
| 165 | + py: 'cpython-3.11' |
| 166 | + options: 'pgo+lto' |
| 167 | + |
| 168 | + - target_triple: 'x86_64-apple-darwin' |
| 169 | + runner: macos-13 |
| 170 | + py: 'cpython-3.12' |
| 171 | + options: 'debug' |
| 172 | + - target_triple: 'x86_64-apple-darwin' |
| 173 | + runner: macos-13 |
| 174 | + py: 'cpython-3.12' |
| 175 | + options: 'pgo' |
| 176 | + - target_triple: 'x86_64-apple-darwin' |
| 177 | + runner: macos-13 |
| 178 | + py: 'cpython-3.12' |
| 179 | + options: 'pgo+lto' |
| 180 | + |
| 181 | + - target_triple: 'x86_64-apple-darwin' |
| 182 | + runner: macos-13 |
| 183 | + py: 'cpython-3.13' |
| 184 | + options: 'debug' |
| 185 | + - target_triple: 'x86_64-apple-darwin' |
| 186 | + runner: macos-13 |
| 187 | + py: 'cpython-3.13' |
| 188 | + options: 'pgo' |
| 189 | + - target_triple: 'x86_64-apple-darwin' |
| 190 | + runner: macos-13 |
| 191 | + py: 'cpython-3.13' |
| 192 | + options: 'pgo+lto' |
| 193 | + - target_triple: 'x86_64-apple-darwin' |
| 194 | + runner: macos-13 |
| 195 | + py: 'cpython-3.13' |
| 196 | + options: 'freethreaded+debug' |
| 197 | + - target_triple: 'x86_64-apple-darwin' |
| 198 | + runner: macos-13 |
| 199 | + py: 'cpython-3.13' |
| 200 | + options: 'freethreaded+pgo' |
| 201 | + - target_triple: 'x86_64-apple-darwin' |
| 202 | + runner: macos-13 |
| 203 | + py: 'cpython-3.13' |
| 204 | + options: 'freethreaded+pgo+lto' |
| 205 | + needs: |
| 206 | + - pythonbuild |
| 207 | + runs-on: ${{ matrix.build.runner }} |
| 208 | + steps: |
| 209 | + - uses: actions/checkout@v4 |
| 210 | + with: |
| 211 | + fetch-depth: 0 |
| 212 | + |
| 213 | + - name: Install Python |
| 214 | + uses: actions/setup-python@v5 |
| 215 | + with: |
| 216 | + python-version: '3.11' |
| 217 | + |
| 218 | + - name: Download pythonbuild |
| 219 | + uses: actions/download-artifact@v4 |
| 220 | + with: |
| 221 | + name: pythonbuild |
| 222 | + path: build |
| 223 | + |
| 224 | + - name: Build |
| 225 | + run: | |
| 226 | + if [ "${{ matrix.build.target_triple }}" = "aarch64-apple-darwin" ]; then |
| 227 | + export APPLE_SDK_PATH=/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk |
| 228 | + elif [ "${{ matrix.build.target_triple }}" = "x86_64-apple-darwin" ]; then |
| 229 | + export APPLE_SDK_PATH=/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk |
| 230 | + else |
| 231 | + echo "unhandled target triple: ${{ matrix.build.target_triple }}" |
| 232 | + exit 1 |
| 233 | + fi |
| 234 | +
|
| 235 | + ./build-macos.py --target-triple ${{ matrix.build.target_triple }} --python ${{ matrix.build.py }} --options ${{ matrix.build.options }} |
| 236 | +
|
| 237 | + - name: Upload Distributions |
| 238 | + uses: actions/upload-artifact@v4 |
| 239 | + with: |
| 240 | + name: ${{ matrix.build.py }}-${{ matrix.build.target_triple }}-${{ matrix.build.options }} |
| 241 | + path: dist/* |
| 242 | + |
| 243 | + - uses: actions/checkout@v4 |
| 244 | + with: |
| 245 | + repository: 'phracker/MacOSX-SDKs' |
| 246 | + ref: master |
| 247 | + path: macosx-sdks |
| 248 | + |
| 249 | + - name: Validate Distribution |
| 250 | + run: | |
| 251 | + chmod +x build/pythonbuild |
| 252 | +
|
| 253 | + build/pythonbuild validate-distribution --macos-sdks-path macosx-sdks --run dist/*.tar.zst |
0 commit comments