Build Native Release Wheels #63
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you under the Apache License, Version 2.0 (the | |
| # "License"); you may not use this file except in compliance | |
| # with the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, | |
| # software distributed under the License is distributed on an | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| # KIND, either express or implied. See the License for the | |
| # specific language governing permissions and limitations | |
| # under the License. | |
| name: Build Native Release Wheels | |
| on: | |
| push: | |
| tags: ['v*'] # NO PATH FILTER - critical for releases | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Bump version | |
| # Pass the tag name from the push so the python package version matches the tag. | |
| run: ./ci/deploy.sh bump_py_version "${{ github.ref_name }}" | |
| shell: bash | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Set up Bazel | |
| uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0 | |
| with: | |
| bazelisk-cache: true | |
| bazelisk-version: '1.x' | |
| - name: Build wheel | |
| shell: bash | |
| run: ./ci/deploy.sh build_pyfory | |
| env: | |
| GITHUB_REF_NAME: ${{ github.ref_name }} | |
| - name: Install and verify wheel | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install dist/*.whl | |
| INSTALLED_VERSION=$(python -c "import pyfory; print(pyfory.__version__)") | |
| echo "Installed version: $INSTALLED_VERSION" | |
| EXPECTED_VERSION="${{ github.ref_name }}" | |
| EXPECTED_VERSION=$(DEPLOY_QUIET=1 ci/deploy.sh parse_py_version $EXPECTED_VERSION | tail -n1) | |
| echo "Expected version: $EXPECTED_VERSION" | |
| if [ "$INSTALLED_VERSION" != "$EXPECTED_VERSION" ]; then | |
| echo "Version mismatch: Expected $EXPECTED_VERSION but got $INSTALLED_VERSION" | |
| exit 1 | |
| fi | |
| echo "Version verification successful" | |
| - name: Upload wheels as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pyfory-wheels-windows-${{ matrix.python-version }}-${{ github.ref_name }} | |
| path: dist/*.whl | |
| build-macos-arm64: | |
| runs-on: macos-15 | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Bump version | |
| run: ./ci/deploy.sh bump_py_version "${{ github.ref_name }}" | |
| shell: bash | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Set up Bazel | |
| uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0 | |
| with: | |
| bazelisk-cache: true | |
| bazelisk-version: '1.x' | |
| - name: Build wheel | |
| shell: bash | |
| run: ./ci/deploy.sh build_pyfory | |
| env: | |
| GITHUB_REF_NAME: ${{ github.ref_name }} | |
| MACOSX_DEPLOYMENT_TARGET: "11.0" | |
| PYFORY_WHEEL_PLAT: macosx_11_0_arm64 | |
| - name: Install and verify wheel | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install dist/*.whl | |
| INSTALLED_VERSION=$(python -c "import pyfory; print(pyfory.__version__)") | |
| echo "Installed version: $INSTALLED_VERSION" | |
| EXPECTED_VERSION="${{ github.ref_name }}" | |
| EXPECTED_VERSION=$(DEPLOY_QUIET=1 ci/deploy.sh parse_py_version $EXPECTED_VERSION | tail -n1) | |
| echo "Expected version: $EXPECTED_VERSION" | |
| if [ "$INSTALLED_VERSION" != "$EXPECTED_VERSION" ]; then | |
| echo "Version mismatch: Expected $EXPECTED_VERSION but got $INSTALLED_VERSION" | |
| exit 1 | |
| fi | |
| echo "Version verification successful" | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pyfory-macos-arm64-wheel-${{ matrix.python-version }}-${{ github.ref_name }} | |
| path: dist/*.whl | |
| build-macos-x86_64: | |
| runs-on: macos-15-intel | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Bump version | |
| run: ./ci/deploy.sh bump_py_version "${{ github.ref_name }}" | |
| shell: bash | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Set up Bazel | |
| uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0 | |
| with: | |
| bazelisk-cache: true | |
| bazelisk-version: '1.x' | |
| - name: Build wheel | |
| shell: bash | |
| run: ./ci/deploy.sh build_pyfory | |
| env: | |
| GITHUB_REF_NAME: ${{ github.ref_name }} | |
| MACOSX_DEPLOYMENT_TARGET: "11.0" | |
| PYFORY_WHEEL_PLAT: macosx_11_0_x86_64 | |
| - name: Install and verify wheel | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install dist/*.whl | |
| INSTALLED_VERSION=$(python -c "import pyfory; print(pyfory.__version__)") | |
| echo "Installed version: $INSTALLED_VERSION" | |
| EXPECTED_VERSION="${{ github.ref_name }}" | |
| EXPECTED_VERSION=$(DEPLOY_QUIET=1 ci/deploy.sh parse_py_version $EXPECTED_VERSION | tail -n1) | |
| echo "Expected version: $EXPECTED_VERSION" | |
| if [ "$INSTALLED_VERSION" != "$EXPECTED_VERSION" ]; then | |
| echo "Version mismatch: Expected $EXPECTED_VERSION but got $INSTALLED_VERSION" | |
| exit 1 | |
| fi | |
| echo "Version verification successful" | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pyfory-macos-x86_64-wheel-${{ matrix.python-version }}-${{ github.ref_name }} | |
| path: dist/*.whl | |
| merge-macos-universal2: | |
| runs-on: macos-15 | |
| needs: [build-macos-arm64, build-macos-x86_64] | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install wheel tooling | |
| run: python -m pip install --upgrade pip wheel | |
| - name: Download arch wheels | |
| uses: actions/download-artifact@v5 | |
| with: | |
| pattern: pyfory-macos-*-wheel-${{ matrix.python-version }}-${{ github.ref_name }} | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Build universal2 wheel | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p unpacked dist | |
| ARM_WHL=$(ls artifacts/*arm64*.whl | head -n1) | |
| X86_WHL=$(ls artifacts/*x86_64*.whl | head -n1) | |
| python -m wheel unpack "$ARM_WHL" -d unpacked/arm64 | |
| python -m wheel unpack "$X86_WHL" -d unpacked/x86_64 | |
| ARM_DIR=$(ls -d unpacked/arm64/pyfory-*) | |
| X86_DIR=$(ls -d unpacked/x86_64/pyfory-*) | |
| UNIVERSAL_DIR="unpacked/pyfory-universal2" | |
| cp -R "$ARM_DIR" "$UNIVERSAL_DIR" | |
| SO_FILES=$(cd "$ARM_DIR" && find pyfory -name '*.so' -type f | sort) | |
| if [[ -z "$SO_FILES" ]]; then | |
| echo "No shared libraries found in wheel payload" | |
| exit 1 | |
| fi | |
| for so in $SO_FILES; do | |
| if [[ ! -f "$X86_DIR/$so" ]]; then | |
| echo "Missing matching x86_64 library for $so" | |
| exit 1 | |
| fi | |
| lipo -create "$ARM_DIR/$so" "$X86_DIR/$so" -output "$UNIVERSAL_DIR/$so" | |
| done | |
| WHEEL_FILE=$(ls "$UNIVERSAL_DIR"/pyfory-*.dist-info/WHEEL) | |
| sed -i '' -e 's/macosx_11_0_arm64/macosx_11_0_universal2/g' \ | |
| -e 's/macosx_11_0_x86_64/macosx_11_0_universal2/g' \ | |
| "$WHEEL_FILE" | |
| python -m wheel pack "$UNIVERSAL_DIR" -d dist | |
| - name: Verify universal2 binaries | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p verify | |
| for whl in dist/*.whl; do | |
| python -m wheel unpack "$whl" -d verify | |
| done | |
| VERIFY_DIR=$(ls -d verify/pyfory-*) | |
| WHEEL_FILE=$(ls "$VERIFY_DIR"/pyfory-*.dist-info/WHEEL) | |
| grep -q "macosx_11_0_universal2" "$WHEEL_FILE" | |
| SO_FILES=$(cd "$VERIFY_DIR" && find pyfory -name '*.so' -type f | sort) | |
| if [[ -z "$SO_FILES" ]]; then | |
| echo "No shared libraries found in packed universal2 wheel" | |
| exit 1 | |
| fi | |
| for so in $SO_FILES; do | |
| ARCHS=$(lipo -archs "$VERIFY_DIR/$so") | |
| echo "$so: $ARCHS" | |
| if [[ "$ARCHS" != *arm64* || "$ARCHS" != *x86_64* ]]; then | |
| echo "Missing expected architectures for $so" | |
| exit 1 | |
| fi | |
| done | |
| - name: Upload universal2 wheel | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pyfory-wheels-macos-universal2-${{ matrix.python-version }}-${{ github.ref_name }} | |
| path: dist/*.whl |