|
| 1 | +name: Build Wheels |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + |
| 10 | +jobs: |
| 11 | + build_sdist: |
| 12 | + name: "sdist" |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest] |
| 18 | + steps: |
| 19 | + - name: Check out repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + submodules: "recursive" |
| 24 | + |
| 25 | + - name: Set up python 3.12 |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: "3.12" |
| 29 | + |
| 30 | + - name: Build sdist |
| 31 | + run: | |
| 32 | + pipx run build --sdist |
| 33 | +
|
| 34 | + - uses: actions/upload-artifact@v4 |
| 35 | + with: |
| 36 | + name: wheels-sdist |
| 37 | + path: dist/*.tar.gz |
| 38 | + |
| 39 | + build_wheels_linux: |
| 40 | + name: "${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }}" |
| 41 | + runs-on: ${{ matrix.os }} |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + os: [ubuntu-latest] |
| 46 | + cibw_build: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"] |
| 47 | + cibw_archs: ["x86_64", "aarch64"] |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Check out repository |
| 51 | + uses: actions/checkout@v4 |
| 52 | + with: |
| 53 | + fetch-depth: 0 |
| 54 | + submodules: "recursive" |
| 55 | + |
| 56 | + - name: Sanitize matrix.cibw_build |
| 57 | + id: sanitize_build |
| 58 | + run: echo "CIBW_BUILD_SANITIZED=$(echo '${{ matrix.cibw_build }}' | sed 's/\*/_/g')" >> $GITHUB_ENV |
| 59 | + shell: bash |
| 60 | + |
| 61 | + - name: Set up QEMU |
| 62 | + if: matrix.cibw_archs != 'x86_64' |
| 63 | + uses: docker/setup-qemu-action@v3 |
| 64 | + with: |
| 65 | + platforms: all |
| 66 | + |
| 67 | + - name: Set up python 3.12 |
| 68 | + uses: actions/setup-python@v5 |
| 69 | + with: |
| 70 | + python-version: "3.12" |
| 71 | + |
| 72 | + - name: Build wheels |
| 73 | + uses: pypa/cibuildwheel@v2.16.5 |
| 74 | + env: |
| 75 | + CIBW_ARCHS: ${{ matrix.cibw_archs }} |
| 76 | + CIBW_BUILD: ${{ matrix.cibw_build }} |
| 77 | + CIBW_BEFORE_ALL: mkdir openexr/build && cd openexr/build && cmake .. -DCMAKE_INSTALL_PREFIX=../../openexr-install && make all install |
| 78 | + CIBW_ENVIRONMENT: LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/openexr-install/lib64:${GITHUB_WORKSPACE}/openexr-install/lib |
| 79 | + |
| 80 | + - uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: wheels-${{ matrix.os }}-${{ env.CIBW_BUILD_SANITIZED }}-${{ matrix.cibw_archs }} |
| 83 | + path: wheelhouse/*.whl |
| 84 | + |
| 85 | + build_wheels_macos: |
| 86 | + name: "${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }}" |
| 87 | + runs-on: ${{ matrix.os }} |
| 88 | + strategy: |
| 89 | + fail-fast: false |
| 90 | + matrix: |
| 91 | + os: [macos-latest] |
| 92 | + cibw_build: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"] |
| 93 | + cibw_archs: ["x86_64"] |
| 94 | + env: |
| 95 | + SYSTEM_VERSION_COMPAT: 0 # https://github.com/actions/setup-python/issues/469#issuecomment-1192522949 |
| 96 | + steps: |
| 97 | + - name: Check out repository |
| 98 | + uses: actions/checkout@v4 |
| 99 | + with: |
| 100 | + fetch-depth: 0 |
| 101 | + submodules: "recursive" |
| 102 | + |
| 103 | + - name: Sanitize matrix.cibw_build |
| 104 | + id: sanitize_build |
| 105 | + run: echo "CIBW_BUILD_SANITIZED=$(echo '${{ matrix.cibw_build }}' | sed 's/\*/_/g')" >> $GITHUB_ENV |
| 106 | + shell: bash |
| 107 | + |
| 108 | + - name: Set up python 3.12 |
| 109 | + uses: actions/setup-python@v5 |
| 110 | + with: |
| 111 | + python-version: "3.12" |
| 112 | + |
| 113 | + - name: Build wheels |
| 114 | + uses: pypa/cibuildwheel@v2.16.5 |
| 115 | + env: |
| 116 | + CIBW_ARCHS: ${{ matrix.cibw_archs }} |
| 117 | + CIBW_BUILD: ${{ matrix.cibw_build }} |
| 118 | + CIBW_BEFORE_ALL: mkdir openexr/build && cd openexr/build && cmake .. -DCMAKE_INSTALL_PREFIX=../../openexr-install && make all install |
| 119 | + CIBW_ENVIRONMENT: LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/openexr-install/lib64:${GITHUB_WORKSPACE}/openexr-install/lib |
| 120 | + CIBW_REPAIR_WHEEL_COMMAND: | |
| 121 | + echo "Target delocate archs: {delocate_archs}" |
| 122 | +
|
| 123 | + ORIGINAL_WHEEL={wheel} |
| 124 | +
|
| 125 | + echo "Running delocate-listdeps to list linked original wheel dependencies" |
| 126 | + delocate-listdeps --all $ORIGINAL_WHEEL |
| 127 | +
|
| 128 | + echo "Running delocate-wheel command on $ORIGINAL_WHEEL" |
| 129 | + DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v $ORIGINAL_WHEEL |
| 130 | +
|
| 131 | + echo "Running delocate-listdeps to list linked wheel dependencies" |
| 132 | + WHEEL_SIMPLE_FILENAME="${ORIGINAL_WHEEL##*/}" |
| 133 | + DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH delocate-listdeps --all {dest_dir}/$WHEEL_SIMPLE_FILENAME |
| 134 | +
|
| 135 | + echo "DONE." |
| 136 | +
|
| 137 | + - uses: actions/upload-artifact@v4 |
| 138 | + with: |
| 139 | + name: wheels-${{ matrix.os }}-${{ env.CIBW_BUILD_SANITIZED }}-${{ matrix.cibw_archs }} |
| 140 | + path: wheelhouse/*.whl |
| 141 | + |
| 142 | + build_wheels_macos_arm64: |
| 143 | + name: "${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }}" |
| 144 | + runs-on: ${{ matrix.os }} |
| 145 | + strategy: |
| 146 | + matrix: |
| 147 | + os: [macos-latest] |
| 148 | + cibw_build: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"] |
| 149 | + cibw_archs: ["arm64"] |
| 150 | + |
| 151 | + steps: |
| 152 | + - name: Check out repository |
| 153 | + uses: actions/checkout@v4 |
| 154 | + with: |
| 155 | + fetch-depth: 0 |
| 156 | + submodules: "recursive" |
| 157 | + |
| 158 | + - name: Sanitize matrix.cibw_build |
| 159 | + id: sanitize_build |
| 160 | + run: echo "CIBW_BUILD_SANITIZED=$(echo '${{ matrix.cibw_build }}' | sed 's/\*/_/g')" >> $GITHUB_ENV |
| 161 | + shell: bash |
| 162 | + |
| 163 | + - uses: actions/setup-python@v5 |
| 164 | + with: |
| 165 | + python-version: "3.12" |
| 166 | + |
| 167 | + - name: Build wheels |
| 168 | + uses: pypa/cibuildwheel@v2.16.5 |
| 169 | + env: |
| 170 | + CIBW_BUILD: ${{ matrix.cibw_build }} |
| 171 | + CIBW_ARCHS: ${{ matrix.cibw_archs }} |
| 172 | + CIBW_BEFORE_ALL: mkdir openexr/build && cd openexr/build && cmake .. -DCMAKE_INSTALL_PREFIX=../../openexr-install && make all install |
| 173 | + CIBW_ENVIRONMENT: LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/openexr-install/lib64:${GITHUB_WORKSPACE}/openexr-install/lib |
| 174 | + CIBW_REPAIR_WHEEL_COMMAND: | |
| 175 | + echo "Target delocate archs: {delocate_archs}" |
| 176 | +
|
| 177 | + ORIGINAL_WHEEL={wheel} |
| 178 | +
|
| 179 | + echo "Running delocate-listdeps to list linked original wheel dependencies" |
| 180 | + delocate-listdeps --all $ORIGINAL_WHEEL |
| 181 | +
|
| 182 | + echo "Renaming .whl file when architecture is 'macosx_arm64'" |
| 183 | + RENAMED_WHEEL=${ORIGINAL_WHEEL//x86_64/arm64} |
| 184 | +
|
| 185 | + echo "Wheel will be renamed to $RENAMED_WHEEL" |
| 186 | + mv $ORIGINAL_WHEEL $RENAMED_WHEEL |
| 187 | +
|
| 188 | + echo "Running delocate-wheel command on $RENAMED_WHEEL" |
| 189 | + delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v $RENAMED_WHEEL |
| 190 | +
|
| 191 | + echo "Running delocate-listdeps to list linked wheel dependencies" |
| 192 | + WHEEL_SIMPLE_FILENAME="${RENAMED_WHEEL##*/}" |
| 193 | + delocate-listdeps --all {dest_dir}/$WHEEL_SIMPLE_FILENAME |
| 194 | +
|
| 195 | + echo "DONE." |
| 196 | +
|
| 197 | + - uses: actions/upload-artifact@v4 |
| 198 | + with: |
| 199 | + name: wheels-${{ matrix.os }}-${{ env.CIBW_BUILD_SANITIZED }}-${{ matrix.cibw_archs }} |
| 200 | + path: ./wheelhouse/*.whl |
| 201 | + |
| 202 | + upload_to_pypi: |
| 203 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 204 | + needs: |
| 205 | + [ |
| 206 | + "build_sdist", |
| 207 | + "build_wheels_linux", |
| 208 | + "build_wheels_macos", |
| 209 | + "build_wheels_macos_arm64", |
| 210 | + ] |
| 211 | + runs-on: ubuntu-latest |
| 212 | + steps: |
| 213 | + - uses: actions/download-artifact@v4 |
| 214 | + with: |
| 215 | + path: wheels |
| 216 | + pattern: wheels-* |
| 217 | + merge-multiple: true |
| 218 | + |
| 219 | + - name: Set up python 3.12 |
| 220 | + uses: actions/setup-python@v5 |
| 221 | + with: |
| 222 | + python-version: "3.12" |
| 223 | + |
| 224 | + - name: Install Twine |
| 225 | + run: pip install twine |
| 226 | + |
| 227 | + - name: Authenticate to Google Cloud |
| 228 | + id: auth |
| 229 | + uses: "google-github-actions/auth@v1" |
| 230 | + with: |
| 231 | + credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" |
| 232 | + |
| 233 | + - name: Upload to Artifact Registry |
| 234 | + run: | |
| 235 | + gcloud config set artifacts/repository OpenEXR |
| 236 | + gcloud config set artifacts/location us-west1 |
| 237 | + gcloud auth activate-service-account --key-file=$GOOGLE_GHA_CREDS_PATH |
| 238 | + gcloud artifacts print-settings python > ~/.pypirc |
| 239 | + python -m twine upload --repository OpenEXR wheels/* |
0 commit comments