Skip to content

Commit

Permalink
Fix dependency typo and unpin cibuildwheel version in wheel building … (
Browse files Browse the repository at this point in the history
google#1263)

* Fix dependency typo and unpin cibuildwheel version in wheel building action

* Move to monolithic build jobs, restrict to x64 architectures

As of this commit, all wheel building jobs complete on GitHub Actions. Since some platform-specific options had to be set to fix different types of build problems underway, the build job matrix was unrolled.

Still left TODO:
* Wheel testing after build (running the Python bindings test)
* Emulating bazel on other architectures to build aarch64/i686/ppc64le
* Enabling Win32 (this fails due to linker errors).

* Add binding test commands for all wheels, set macOSX deployment target to 10.9

* Add instructions for updating Python __version__ variable before release creation
  • Loading branch information
nicholasjng authored and sergiud committed Jan 13, 2022
1 parent f6c228e commit b0a9a1e
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 15 deletions.
101 changes: 88 additions & 13 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Build and upload Python wheels

on:
workflow_dispatch:
release:
types:
- published

jobs:
build_sdist:
Expand All @@ -19,21 +22,89 @@ jobs:
- name: Build and check sdist
run: |
python setup.py sdist
ls -al dist/
- name: Upload sdist
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/*.tar.gz

build_wheels:
name: Build google-benchmark wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
# let runner finish even if there is a failure
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
build_linux:
name: Build google-benchmark manylinux wheels
runs-on: ubuntu-latest

steps:
- name: Check out Google Benchmark
uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

# TODO: Bazel does not seem to work in an emulated Docker environment, see
# https://github.com/bazelbuild/bazel/issues/11379
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v1
# with:
# platforms: all

- name: Build Python wheels on ubuntu-latest
env:
CIBW_BUILD: 'cp37-* cp38-* cp39-* cp310-*'
CIBW_SKIP: "*-musllinux_*"
# Bazel repo only exists on CentOS 7 for x86 and ppc, so no manylinux2010
# TODO: Build ppc64le, aarch64 using some other trick
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_ARCHS_LINUX: x86_64
CIBW_BEFORE_ALL: >
curl -O --retry-delay 5 --retry 5 https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo &&
cp vbatts-bazel-epel-7.repo /etc/yum.repos.d/bazel.repo &&
yum install -y bazel4
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
run: |
pip install cibuildwheel
python -m cibuildwheel --output-dir wheelhouse
- name: Upload Linux wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: wheelhouse/*.whl

build_macos:
name: Build google-benchmark macOS wheels
runs-on: macos-latest

steps:
- name: Check out Google Benchmark
uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Build Python wheels on macOS
env:
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_BUILD: 'cp37-* cp38-* cp39-* cp310-*'
# ARM64 requires Python 3.8 minimum
CIBW_SKIP: 'cp37-*-arm64'
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
CIBW_TEST_SKIP: "*_arm64"
run: |
pip install cibuildwheel
python -m cibuildwheel --output-dir wheelhouse
- name: Upload macOS wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: wheelhouse/*.whl

build_windows:
name: Build google-benchmark wheels on Windows
runs-on: windows-latest

steps:
- name: Check out Google Benchmark
Expand All @@ -44,15 +115,19 @@ jobs:
with:
python-version: 3.9

- name: Build Python wheels on ${{ matrix.os }}
- name: Build Python wheels on Windows
env:
CIBW_BUILD: 'cp36-* cp37-* cp38-* cp39-*'
CIBW_BUILD: 'cp37-* cp38-* cp39-* cp310-*'
CIBW_ARCHS_WINDOWS: AMD64
# otherwise, pip crashes the job by trying to remove an in-use bazel DLL
PIP_NO_CLEAN: true
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
run: |
pip install cibuildwheelcibuildwheel==2.0.0a2
pip install cibuildwheel
python -m cibuildwheel --output-dir wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: ./wheelhouse/*.whl
path: wheelhouse/*.whl
17 changes: 15 additions & 2 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@
* `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of
commits between the last annotated tag and HEAD
* Pick the most interesting.
* Create one last commit that updates the version saved in `CMakeLists.txt` to the release version you're creating. (This version will be used if benchmark is installed from the archive you'll be creating in the next step.)
* Create one last commit that updates the version saved in `CMakeLists.txt` and the
`__version__` variable in `bindings/python/google_benchmark/__init__.py`to the release
version you're creating. (This version will be used if benchmark is installed from the
archive you'll be creating in the next step.)

```
project (benchmark VERSION 1.5.3 LANGUAGES CXX)
project (benchmark VERSION 1.6.0 LANGUAGES CXX)
```

```python
# bindings/python/google_benchmark/__init__.py

# ...

__version__ = "1.6.0" # <-- change this to the release version you are creating

# ...
```

* Create a release through github's interface
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import posixpath
import platform
import re
import shutil
import sys
Expand Down Expand Up @@ -89,6 +90,8 @@ def bazel_build(self, ext):
# Link with python*.lib.
for library_dir in self.library_dirs:
bazel_argv.append("--linkopt=/LIBPATH:" + library_dir)
elif sys.platform == "darwin" and platform.machine() == "x86_64":
bazel_argv.append("--macos_minimum_os=10.9")

self.spawn(bazel_argv)

Expand Down

0 comments on commit b0a9a1e

Please sign in to comment.