Skip to content

Commit ada6cb0

Browse files
authored
Merge branch 'main' into c++17
2 parents 7339256 + a6af6ee commit ada6cb0

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

.github/workflows/test_bindings.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ on:
88

99
jobs:
1010
python_bindings:
11-
name: Test GBM Python bindings on ${{ matrix.os }}
11+
name: Test GBM Python ${{ matrix.python-version }} bindings on ${{ matrix.os }}
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
os: [ ubuntu-latest, macos-latest, windows-latest ]
17+
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
1718

1819
steps:
1920
- uses: actions/checkout@v4
2021
with:
2122
fetch-depth: 0
22-
- name: Set up Python 3.11
23+
- name: Set up Python ${{ matrix.python-version }}
2324
uses: actions/setup-python@v5
2425
with:
25-
python-version: 3.11
26+
python-version: ${{ matrix.python-version }}
2627
- name: Install GBM Python bindings on ${{ matrix.os }}
2728
run: python -m pip install .
28-
- name: Run bindings example on ${{ matrix.os }}
29-
run:
30-
python bindings/python/google_benchmark/example.py
29+
- name: Run example on ${{ matrix.os }} under Python ${{ matrix.python-version }}
30+
run: python bindings/python/google_benchmark/example.py

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
platforms: all
5454

5555
- name: Build wheels on ${{ matrix.os }} using cibuildwheel
56-
uses: pypa/cibuildwheel@v2.20
56+
uses: pypa/cibuildwheel@v2.21.3
5757
env:
5858
CIBW_BUILD: "cp310-* cp311-* cp312-*"
5959
CIBW_BUILD_FRONTEND: "build[uv]"

.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: 7.1.2
3+
rev: 7.3.1
44
hooks:
55
- id: buildifier
66
- id: buildifier-lint
77
- repo: https://github.com/pre-commit/mirrors-mypy
8-
rev: v1.11.1
8+
rev: v1.13.0
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.6.1
14+
rev: v0.7.2
1515
hooks:
1616
- id: ruff
1717
args: [ --fix, --exit-non-zero-on-fix ]

setup.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import platform
44
import re
55
import shutil
6+
import sys
67
from pathlib import Path
78
from typing import Any, Generator
89

@@ -15,8 +16,7 @@
1516

1617
# hardcoded SABI-related options. Requires that each Python interpreter
1718
# (hermetic or not) participating is of the same major-minor version.
18-
version_tuple = tuple(int(i) for i in platform.python_version_tuple())
19-
py_limited_api = version_tuple >= (3, 12)
19+
py_limited_api = sys.version_info >= (3, 12)
2020
options = {"bdist_wheel": {"py_limited_api": "cp312"}} if py_limited_api else {}
2121

2222

@@ -43,10 +43,10 @@ def fmt_toolchain_args(matchobj):
4343
return "python.toolchain(" + callargs + ")"
4444

4545
CIBW_LINUX = is_cibuildwheel() and IS_LINUX
46+
module_bazel = Path("MODULE.bazel")
47+
content: str = module_bazel.read_text()
4648
try:
4749
if CIBW_LINUX:
48-
module_bazel = Path("MODULE.bazel")
49-
content: str = module_bazel.read_text()
5050
module_bazel.write_text(
5151
re.sub(
5252
r"python.toolchain\(([\w\"\s,.=]*)\)",
@@ -92,10 +92,16 @@ def copy_extensions_to_source(self):
9292
def bazel_build(self, ext: BazelExtension) -> None:
9393
"""Runs the bazel build to create the package."""
9494
temp_path = Path(self.build_temp)
95-
# omit the patch version to avoid build errors if the toolchain is not
96-
# yet registered in the current @rules_python version.
97-
# patch version differences should be fine.
98-
python_version = ".".join(platform.python_version_tuple()[:2])
95+
if py_limited_api:
96+
# We only need to know the minimum ABI version,
97+
# since it is stable across minor versions by definition.
98+
# The value here is calculated as the minimum of a) the minimum
99+
# Python version required, and b) the stable ABI version target.
100+
# NB: This needs to be kept in sync with [project.requires-python]
101+
# in pyproject.toml.
102+
python_version = "3.12"
103+
else:
104+
python_version = "{0}.{1}".format(*sys.version_info[:2])
99105

100106
bazel_argv = [
101107
"bazel",

0 commit comments

Comments
 (0)