[SymForce] Update cibuildwheel to v3 #125
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
| name: Build wheels | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - 'v*.*.*' | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| workflow_dispatch: | |
| jobs: | |
| build-extra: | |
| if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) || (github.event_name == 'pull_request' && github.event.pull_request.draft == false) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| # Should include history since the last tag for setuptools_scm to work | |
| fetch-depth: 300 | |
| fetch-tags: true | |
| - name: Build Wheels | |
| run: | | |
| pip3 install build | |
| python3 -m build --sdist --wheel third_party/skymarshal --outdir ./dist | |
| python3 -m build --sdist --wheel gen/python --outdir ./dist | |
| - name: Upload Wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: symforce-wheels-extra | |
| path: dist/* | |
| build-macos: | |
| if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) || (github.event_name == 'pull_request' && github.event.pull_request.draft == false) | |
| runs-on: ${{ matrix.os.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - deploy_target: 14.0 | |
| runner: macos-14 | |
| arch: arm64 | |
| python-version: [cp38, cp39, cp310, cp311, cp312] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| # Should include history since the last tag for setuptools_scm to work | |
| fetch-depth: 300 | |
| fetch-tags: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - run: pip install setuptools_scm | |
| - run: echo "SYMFORCE_VERSION=$(python -m setuptools_scm)" | tee $GITHUB_ENV | |
| - name: Build wheels | |
| uses: pypa/[email protected] | |
| env: | |
| CIBW_BUILD: ${{ matrix.python-version }}-* | |
| CIBW_ARCHS_MACOS: ${{ matrix.os.arch }} | |
| # For arm64; for x86, it's at /usr/local but cmake finds that ok already | |
| GMP_ROOT: /opt/homebrew | |
| CIBW_ENVIRONMENT: SYMFORCE_REWRITE_LOCAL_DEPENDENCIES=$SYMFORCE_VERSION MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.deploy_target }} SYMFORCE_PYTHON_OVERRIDE=python | |
| CIBW_BEFORE_TEST: > | |
| pip install build setuptools_scm && | |
| python -m build --wheel {project}/third_party/skymarshal --outdir /tmp/wheel-test-dist && | |
| python -m build --wheel {project}/gen/python --outdir /tmp/wheel-test-dist && | |
| pip install /tmp/wheel-test-dist/* | |
| CIBW_TEST_COMMAND: python {project}/.github/scripts/run_wheel_tests.py {project} | |
| CIBW_TEST_EXTRAS: dev | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: symforce-wheels-${{ matrix.os.arch }}-${{ matrix.python-version }} | |
| path: wheelhouse/*.whl | |
| build-linux: | |
| if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) || (github.event_name == 'pull_request' && github.event.pull_request.draft == false) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| python-version: [cp38, cp39, cp310, cp311, cp312] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| # Should include history since the last tag for setuptools_scm to work | |
| fetch-depth: 300 | |
| fetch-tags: true | |
| - run: python3 -m pip install setuptools_scm | |
| - run: echo "SYMFORCE_VERSION=$(python3 -m setuptools_scm)" | tee $GITHUB_ENV | |
| - name: Build wheels | |
| uses: pypa/[email protected] | |
| env: | |
| CIBW_BUILD: ${{ matrix.python-version }}-manylinux_x86_64 | |
| CIBW_BEFORE_BUILD: yum install -y gmp-devel git | |
| CIBW_ENVIRONMENT: SYMFORCE_REWRITE_LOCAL_DEPENDENCIES=$SYMFORCE_VERSION SYMFORCE_PYTHON_OVERRIDE=python | |
| CIBW_ENVIRONMENT_PASS_LINUX: SYMFORCE_VERSION | |
| CIBW_BEFORE_TEST: > | |
| pip install build setuptools_scm && | |
| python -m build --wheel {project}/third_party/skymarshal --outdir /tmp/wheel-test-dist && | |
| python -m build --wheel {project}/gen/python --outdir /tmp/wheel-test-dist && | |
| pip install /tmp/wheel-test-dist/* | |
| # Need to install prettier for typescript codegen | |
| CIBW_TEST_COMMAND: source {project}/.github/scripts/install_prettier.sh && python {project}/.github/scripts/run_wheel_tests.py {project} | |
| CIBW_TEST_EXTRAS: dev | |
| - name: Upload Wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: symforce-wheels-${{ matrix.os }}-${{ matrix.python-version }} | |
| path: wheelhouse/*.whl | |
| merge-wheel-artifacts: | |
| if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) || (github.event_name == 'pull_request' && github.event.pull_request.draft == false) | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-extra | |
| - build-macos | |
| - build-linux | |
| steps: | |
| - uses: actions/upload-artifact/merge@v4 | |
| with: | |
| name: symforce-wheels | |
| delete-merged: true | |
| publish-to-pypi: | |
| name: Publish Python 🐍 distribution 📦 to PyPI | |
| strategy: | |
| matrix: | |
| package: [symforce, symforce_sym, skymarshal] | |
| if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
| needs: | |
| - merge-wheel-artifacts | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/${{ matrix.package }} | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: symforce-wheels | |
| path: wheels-download/ | |
| - run: mkdir dist && cp wheels-download/${{ matrix.package }}-*.whl dist/ | |
| - name: Publish distribution 📦 to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |