benchmark/.github/workflows/wheels.yml

101 lines
2.8 KiB
YAML
Raw Permalink Normal View History

name: Build and upload Python wheels
on:
workflow_dispatch:
release:
types:
- published
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python -m pip install build
- name: Build sdist
run: python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist/*.tar.gz
build_wheels:
name: Build Google Benchmark wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13, macos-14, windows-latest]
steps:
- name: Check out Google Benchmark
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python 3.12
with:
python-version: "3.12"
- run: pip install --upgrade pip uv
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build wheels on ${{ matrix.os }} using cibuildwheel
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_BUILD: "cp310-* cp311-* cp312-*"
CIBW_BUILD_FRONTEND: "build[uv]"
Switch bindings implementation to `nanobind` (#1526) * End support for Python 3.7, update cibuildwheel and publish actions Removes Python 3.7 from the support matrix, since it does not support PEP590 vectorcalls. Bumps the `cibuildwheel` and `pypa-publish` actions to their latest available versions respectively. * Add nanobind to the Bazel dependencies, add a BUILD file The build file builds nanobind as a static `cc_library`. Currently, the git SHA points to HEAD, since some necessary features have not been included in a release yet. * Delete pybind11 BUILD file * Switch bindings implementation to nanobind Switches over the binding tool to `nanobind` from `pybind11`. Most changes in the build setup itself were drop-in replacements of existing code changed to nanobind names, no new concepts needed to be implemented. Sets the minimum required macOS to 10.14 for full C++17 support. Also, to avoid ambiguities in Bazel, build for macOS 11 on Mac ARM64. * Use Bazel select for linker options Guards against unknown linker option errors by selecting required linker options for nanobind only on macOS, where they are relevant. Other changes: * Bump cibuildwheel action to v2.12.0 * Bump Bazel for aarch64 linux wheels to 6.0.0 * Remove C++17 flag from build files since it is present in setup.py `bazel build` command * Bump nanobind commit to current HEAD (TBD: Bump to next stable release) * Unbreak Windows builds of nanobind-based bindings Guards compiler options behind a new `select` macro choosing between MSVC and not MSVC. Other changes: * Inject the proper C++17 standard cxxopt in the `setup.py` build command. * Bump nanobind to current HEAD. * Make `macos` a benchmark-wide condition, with public visibility to allow its use in the nanobind BUILD file. * Fall back to `nb::implicitly_convertible` for Counter construction Since `benchmark::Counter` only has a constructor for `double`, the nanobind `nb::init_implicit` template cannot be used. Therefore, to support implicit construction from ints, we fall back to the `nb::implicitly_convertible` template instead.
2023-02-06 13:07:17 +00:00
CIBW_SKIP: "*-musllinux_*"
CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
CIBW_ARCHS_LINUX: auto64 aarch64
CIBW_ARCHS_WINDOWS: auto64
CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh
# Grab the rootless Bazel installation inside the container.
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
# unused by Bazel, but needed explicitly by delocate on MacOS.
MACOSX_DEPLOYMENT_TARGET: "10.14"
- name: Upload Google Benchmark ${{ matrix.os }} wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
path: wheelhouse/*.whl
merge_wheels:
name: Merge all built wheels into one artifact
runs-on: ubuntu-latest
needs: build_wheels
steps:
- name: Merge wheels
uses: actions/upload-artifact/merge@v4
with:
name: dist
pattern: dist-*
delete-merged: true
pypi_upload:
name: Publish google-benchmark wheels to PyPI
needs: [merge_wheels]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1