|
| 1 | +name: Build wheels |
| 2 | + |
| 3 | +env: |
| 4 | + DEPLOY_DIR: "deploy/pypi/zuban" |
| 5 | + DEFAULT_ARCH: "x64" |
| 6 | + |
| 7 | +defaults: |
| 8 | + run: |
| 9 | + shell: bash |
| 10 | + working-directory: "deploy/pypi/zuban" |
| 11 | + |
| 12 | +on: |
| 13 | + workflow_call: |
| 14 | + inputs: |
| 15 | + python_version: |
| 16 | + default: "3.11" |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + t: |
| 25 | + - os: ubuntu-24.04 |
| 26 | + arch: x64 |
| 27 | + target: x86_64-unknown-linux-gnu |
| 28 | + test: native |
| 29 | + |
| 30 | + - os: ubuntu-24.04-arm |
| 31 | + arch: arm64 |
| 32 | + target: aarch64-unknown-linux-gnu |
| 33 | + test: native |
| 34 | + # see https://github.com/astral-sh/ruff/issues/3791 |
| 35 | + # and https://github.com/gnzlbg/jemallocator/issues/170#issuecomment-1503228963 |
| 36 | + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 |
| 37 | + |
| 38 | + # The macos-15-intel runner still supports x64, see https://github.com/actions/runner-images/issues/13045 |
| 39 | + - os: macos-15-intel |
| 40 | + arch: x64 |
| 41 | + target: x86_64 |
| 42 | + test: native |
| 43 | + - os: macos-latest |
| 44 | + arch: arm64 |
| 45 | + target: aarch64 |
| 46 | + test: native |
| 47 | + |
| 48 | + - os: windows-2022 |
| 49 | + arch: x64 |
| 50 | + target: x86_64-pc-windows-msvc |
| 51 | + - os: windows-2022 |
| 52 | + arch: x86 |
| 53 | + target: i686-pc-windows-msvc |
| 54 | + test: native |
| 55 | + |
| 56 | + # manylinux armv7 / x86 (i686) |
| 57 | + - os: ubuntu-24.04 |
| 58 | + arch: armv7 |
| 59 | + target: armv7-unknown-linux-gnueabihf |
| 60 | + test: run-on-arch |
| 61 | + distro: ubuntu24.04 |
| 62 | + install_cmd: apt-get update && apt-get install -y python3 python3-pip python3-venv |
| 63 | + - os: ubuntu-24.04 |
| 64 | + arch: x86 |
| 65 | + target: i686-unknown-linux-gnu |
| 66 | + test: container |
| 67 | + image: i386/python:${{ inputs.python_version }}-slim-trixie |
| 68 | + install_cmd: apt-get install -y bash |
| 69 | + |
| 70 | + # musllinux armv7 / aarch64 (arm64) / x64 / x86 (i686) |
| 71 | + - os: ubuntu-24.04 |
| 72 | + arch: armv7 |
| 73 | + target: armv7-unknown-linux-musleabihf |
| 74 | + manylinux: musllinux_1_2 |
| 75 | + test: run-on-arch |
| 76 | + distro: alpine_latest |
| 77 | + install_cmd: apk add python3 py3-pip bash |
| 78 | + - os: ubuntu-24.04-arm |
| 79 | + target: aarch64-unknown-linux-musl |
| 80 | + # see https://github.com/astral-sh/ruff/issues/3791 |
| 81 | + # and https://github.com/gnzlbg/jemallocator/issues/170#issuecomment-1503228963 |
| 82 | + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 |
| 83 | + manylinux: musllinux_1_2 |
| 84 | + test: container |
| 85 | + image: python:${{ inputs.python_version }}-alpine |
| 86 | + install_cmd: apk add bash |
| 87 | + - os: ubuntu-24.04 |
| 88 | + target: x86_64-unknown-linux-musl |
| 89 | + manylinux: musllinux_1_2 |
| 90 | + test: container |
| 91 | + image: python:${{ inputs.python_version }}-alpine |
| 92 | + install_cmd: apk add bash |
| 93 | + - os: ubuntu-24.04 |
| 94 | + target: i686-unknown-linux-musl |
| 95 | + manylinux: musllinux_1_2 |
| 96 | + test: container |
| 97 | + image: i386/python:${{ inputs.python_version }}-alpine |
| 98 | + install_cmd: apk add bash |
| 99 | + runs-on: ${{ matrix.t.os }} |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v4 |
| 102 | + with: |
| 103 | + submodules: recursive |
| 104 | + persist-credentials: false |
| 105 | + - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 |
| 106 | + with: |
| 107 | + # The target is needed, because there were issues when reusing |
| 108 | + # caches, probably related to cross compiling. |
| 109 | + key: "swatinem-${{ matrix.t.target }}" |
| 110 | + - name: "Pre-Build" |
| 111 | + run: ./pre-maturin-build.sh |
| 112 | + - name: "Build Wheel" |
| 113 | + uses: PyO3/maturin-action@v1 |
| 114 | + with: |
| 115 | + target: ${{ matrix.t.target }} |
| 116 | + working-directory: ${{ env.DEPLOY_DIR }} |
| 117 | + docker-options: ${{ matrix.t.maturin_docker_options }} |
| 118 | + manylinux: ${{ matrix.t.manylinux || 'auto' }} |
| 119 | + args: --release --locked --out dist --ignore-rust-version |
| 120 | + - uses: actions/setup-python@v5 |
| 121 | + if: matrix.t.test == 'native' |
| 122 | + with: |
| 123 | + python-version: ${{ inputs.python_version }} |
| 124 | + architecture: ${{ matrix.t.arch || env.DEFAULT_ARCH }} |
| 125 | + - name: "Test wheel (native)" |
| 126 | + if: matrix.t.test == 'native' |
| 127 | + run: ./test-maturin-build.sh |
| 128 | + - name: "Test wheel (run-on-arch)" |
| 129 | + if: matrix.t.test == 'run-on-arch' |
| 130 | + uses: uraimo/run-on-arch-action@v3 |
| 131 | + with: |
| 132 | + arch: ${{ matrix.t.arch }} |
| 133 | + distro: ${{ matrix.t.distro }} |
| 134 | + githubToken: ${{ github.token }} |
| 135 | + install: | |
| 136 | + ${{ matrix.t.install_cmd }} |
| 137 | + run: | |
| 138 | + cd ${{ env.DEPLOY_DIR }} |
| 139 | + python3 -m venv venv |
| 140 | + . ./venv/bin/activate |
| 141 | + ./test-maturin-build.sh |
| 142 | + - name: "Test wheel (container)" |
| 143 | + if: matrix.t.test == 'container' |
| 144 | + uses: addnab/docker-run-action@v3 |
| 145 | + with: |
| 146 | + image: ${{ matrix.t.image }} |
| 147 | + options: -v ${{ github.workspace }}:/workspace -w /workspace |
| 148 | + run: | |
| 149 | + ${{ matrix.t.install_cmd }} |
| 150 | + cd ${{ env.DEPLOY_DIR }} |
| 151 | + python3 -m venv venv |
| 152 | + . ./venv/bin/activate |
| 153 | + ./test-maturin-build.sh |
| 154 | + - name: "Upload wheel as a GitHub Artifact" |
| 155 | + uses: actions/upload-artifact@v4 |
| 156 | + with: |
| 157 | + name: wheels-${{ matrix.t.os }}-${{ matrix.t.target }} |
| 158 | + path: "${{ env.DEPLOY_DIR }}/dist" |
0 commit comments