Skip to content

Commit 986423a

Browse files
authored
Bump oldest supported Python to 3.10, eliminate setuptools-scm (#1842)
* Supply MacOS deployment target to delocate, use build+uv frontend This shaves off multiple minutes from the wheel builds alone. Also revert to trusted publishing for wheel uploads as it is now set up. * Bump oldest supported Python to 3.10, eliminate setuptools-scm The version is now a string again, under the same attribute as it was before. This is a pragmatic decision in order to be able to upload wheels again, possibly directly from main. We could in the future also set the Python version to a development version if we want to avoid accidental uploads of `main`. * Add a note on supported Python versions in the docs Also fixes the setuptools failure observed in the latest CI by pinning to the last version before v73 until the problem is identified and resolved.
1 parent c19cfee commit 986423a

File tree

8 files changed

+47
-93
lines changed

8 files changed

+47
-93
lines changed

.github/workflows/wheels.yml

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install Python 3.12
1919
uses: actions/setup-python@v5
2020
with:
21-
python-version: 3.12
21+
python-version: "3.12"
2222
- run: python -m pip install build
2323
- name: Build sdist
2424
run: python -m build --sdist
@@ -40,68 +40,23 @@ jobs:
4040
with:
4141
fetch-depth: 0
4242

43+
- uses: actions/setup-python@v5
44+
name: Install Python 3.12
45+
with:
46+
python-version: "3.12"
47+
- run: pip install --upgrade pip uv
48+
4349
- name: Set up QEMU
4450
if: runner.os == 'Linux'
4551
uses: docker/setup-qemu-action@v3
4652
with:
4753
platforms: all
4854

49-
- name: Build 3.8 wheels on ${{ matrix.os }} using cibuildwheel
50-
uses: pypa/cibuildwheel@v2.20
51-
env:
52-
CIBW_BUILD: "cp38-*"
53-
CIBW_SKIP: "*-musllinux_*"
54-
CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
55-
CIBW_ARCHS_LINUX: auto64 aarch64
56-
CIBW_ARCHS_WINDOWS: auto64
57-
CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh
58-
# Grab the rootless Bazel installation inside the container.
59-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin
60-
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
61-
62-
- name: Build 3.9 wheels on ${{ matrix.os }} using cibuildwheel
63-
uses: pypa/cibuildwheel@v2.20
64-
env:
65-
CIBW_BUILD: "cp39-*"
66-
CIBW_SKIP: "*-musllinux_*"
67-
CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
68-
CIBW_ARCHS_LINUX: auto64 aarch64
69-
CIBW_ARCHS_WINDOWS: auto64
70-
CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh
71-
# Grab the rootless Bazel installation inside the container.
72-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin
73-
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
74-
75-
- name: Build 3.10 wheels on ${{ matrix.os }} using cibuildwheel
55+
- name: Build wheels on ${{ matrix.os }} using cibuildwheel
7656
uses: pypa/cibuildwheel@v2.20
7757
env:
78-
CIBW_BUILD: "cp310-*"
79-
CIBW_SKIP: "*-musllinux_*"
80-
CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
81-
CIBW_ARCHS_LINUX: auto64 aarch64
82-
CIBW_ARCHS_WINDOWS: auto64
83-
CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh
84-
# Grab the rootless Bazel installation inside the container.
85-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin
86-
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
87-
88-
- name: Build 3.11 wheels on ${{ matrix.os }} using cibuildwheel
89-
uses: pypa/cibuildwheel@v2.20
90-
env:
91-
CIBW_BUILD: "cp311-*"
92-
CIBW_SKIP: "*-musllinux_*"
93-
CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
94-
CIBW_ARCHS_LINUX: auto64 aarch64
95-
CIBW_ARCHS_WINDOWS: auto64
96-
CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh
97-
# Grab the rootless Bazel installation inside the container.
98-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin
99-
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
100-
101-
- name: Build 3.12 wheels on ${{ matrix.os }} using cibuildwheel
102-
uses: pypa/cibuildwheel@v2.20
103-
env:
104-
CIBW_BUILD: "cp312-*"
58+
CIBW_BUILD: "cp310-* cp311-* cp312-*"
59+
CIBW_BUILD_FRONTEND: "build[uv]"
10560
CIBW_SKIP: "*-musllinux_*"
10661
CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
10762
CIBW_ARCHS_LINUX: auto64 aarch64
@@ -110,6 +65,8 @@ jobs:
11065
# Grab the rootless Bazel installation inside the container.
11166
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin
11267
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py
68+
# unused by Bazel, but needed explicitly by delocate on MacOS.
69+
MACOSX_DEPLOYMENT_TARGET: "10.14"
11370

11471
- name: Upload Google Benchmark ${{ matrix.os }} wheels
11572
uses: actions/upload-artifact@v4
@@ -133,11 +90,11 @@ jobs:
13390
name: Publish google-benchmark wheels to PyPI
13491
needs: [merge_wheels]
13592
runs-on: ubuntu-latest
93+
if: github.event_name == 'release' && github.event.action == 'published'
94+
permissions:
95+
id-token: write
13696
steps:
13797
- uses: actions/download-artifact@v4
13898
with:
13999
path: dist
140100
- uses: pypa/gh-action-pypi-publish@release/v1
141-
with:
142-
user: __token__
143-
password: ${{ secrets.PYPI_PASSWORD }}

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
repos:
22
- repo: https://github.com/keith/pre-commit-buildifier
3-
rev: 6.4.0
3+
rev: 7.1.2
44
hooks:
55
- id: buildifier
66
- id: buildifier-lint
77
- repo: https://github.com/pre-commit/mirrors-mypy
8-
rev: v1.11.0
8+
rev: v1.11.1
99
hooks:
1010
- id: mypy
1111
types_or: [ python, pyi ]
1212
args: [ "--ignore-missing-imports", "--scripts-are-modules" ]
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.4.10
14+
rev: v0.6.1
1515
hooks:
1616
- id: ruff
1717
args: [ --fix, --exit-non-zero-on-fix ]

bindings/python/google_benchmark/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def my_benchmark(state):
4949
oNone as oNone,
5050
oNSquared as oNSquared,
5151
)
52-
from google_benchmark.version import __version__ as __version__
52+
53+
__version__ = "1.9.0"
5354

5455

5556
class __OptionMaker:

bindings/python/google_benchmark/version.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/dependencies.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ distributions include newer versions, for example:
1111
* Ubuntu 20.04 provides CMake 3.16.3
1212
* Debian 11.4 provides CMake 3.18.4
1313
* Ubuntu 22.04 provides CMake 3.22.1
14+
15+
## Python
16+
17+
The Python bindings require Python 3.10+ as of v1.9.0 (2024-08-16) for installation from PyPI.
18+
Building from source for older versions probably still works, though. See the [user guide](python_bindings.md) for details on how to build from source.
19+
The minimum theoretically supported version is Python 3.8, since the used bindings generator (nanobind) only supports Python 3.8+.

docs/releasing.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,24 @@
88
* `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of
99
commits between the last annotated tag and HEAD
1010
* Pick the most interesting.
11-
* Create one last commit that updates the version saved in `CMakeLists.txt` and `MODULE.bazel`
12-
to the release version you're creating. (This version will be used if benchmark is installed
13-
from the archive you'll be creating in the next step.)
11+
* Create one last commit that updates the version saved in `CMakeLists.txt`, `MODULE.bazel`,
12+
and `bindings/python/google_benchmark/__init__.py` to the release version you're creating.
13+
(This version will be used if benchmark is installed from the archive you'll be creating
14+
in the next step.)
1415

1516
```
16-
project (benchmark VERSION 1.8.0 LANGUAGES CXX)
17+
# CMakeLists.txt
18+
project (benchmark VERSION 1.9.0 LANGUAGES CXX)
1719
```
1820

1921
```
20-
module(name = "com_github_google_benchmark", version="1.8.0")
22+
# MODULE.bazel
23+
module(name = "com_github_google_benchmark", version="1.9.0")
24+
```
25+
26+
```
27+
# google_benchmark/__init__.py
28+
__version__ = "1.9.0"
2129
```
2230

2331
* Create a release through github's interface
@@ -28,4 +36,3 @@ module(name = "com_github_google_benchmark", version="1.8.0")
2836
* `git push --force --tags origin`
2937
* Confirm that the "Build and upload Python wheels" action runs to completion
3038
* Run it manually if it hasn't run.
31-
* IMPORTANT: When re-running manually, make sure to select the newly created `<tag>` as the workflow version in the "Run workflow" tab on the GitHub Actions page.

pyproject.toml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-scm[toml]", "wheel"]
2+
requires = ["setuptools<73"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "google_benchmark"
77
description = "A library to benchmark code snippets."
8-
requires-python = ">=3.8"
9-
license = {file = "LICENSE"}
8+
requires-python = ">=3.10"
9+
license = { file = "LICENSE" }
1010
keywords = ["benchmark"]
1111

12-
authors = [
13-
{name = "Google", email = "benchmark-discuss@googlegroups.com"},
14-
]
12+
authors = [{ name = "Google", email = "benchmark-discuss@googlegroups.com" }]
1513

1614
classifiers = [
1715
"Development Status :: 4 - Beta",
1816
"Intended Audience :: Developers",
1917
"Intended Audience :: Science/Research",
2018
"License :: OSI Approved :: Apache Software License",
21-
"Programming Language :: Python :: 3.8",
22-
"Programming Language :: Python :: 3.9",
2319
"Programming Language :: Python :: 3.10",
2420
"Programming Language :: Python :: 3.11",
2521
"Programming Language :: Python :: 3.12",
@@ -29,14 +25,10 @@ classifiers = [
2925

3026
dynamic = ["readme", "version"]
3127

32-
dependencies = [
33-
"absl-py>=0.7.1",
34-
]
28+
dependencies = ["absl-py>=0.7.1"]
3529

3630
[project.optional-dependencies]
37-
dev = [
38-
"pre-commit>=3.3.3",
39-
]
31+
dev = ["pre-commit>=3.3.3"]
4032

4133
[project.urls]
4234
Homepage = "https://github.com/google/benchmark"
@@ -45,16 +37,15 @@ Repository = "https://github.com/google/benchmark.git"
4537
Discord = "https://discord.gg/cz7UX7wKC2"
4638

4739
[tool.setuptools]
48-
package-dir = {"" = "bindings/python"}
40+
package-dir = { "" = "bindings/python" }
4941
zip-safe = false
5042

5143
[tool.setuptools.packages.find]
5244
where = ["bindings/python"]
5345

5446
[tool.setuptools.dynamic]
5547
readme = { file = "README.md", content-type = "text/markdown" }
56-
57-
[tool.setuptools_scm]
48+
version = { attr = "google_benchmark.__version__" }
5849

5950
[tool.mypy]
6051
check_untyped_defs = true

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def bazel_build(self, ext: BazelExtension) -> None:
138138
dirs[:] = [d for d in dirs if "runfiles" not in d]
139139

140140
for f in files:
141-
print(f)
142141
fp = Path(f)
143142
should_copy = False
144143
# we do not want the bare .so file included

0 commit comments

Comments
 (0)