Skip to content

Commit aacf2b1

Browse files
macandy13Andy Christiansen
and
Andy Christiansen
authored
Add support for bzlmod (excluding Python bindings) (google#1615)
* Migrate to bzlmod * Update Python version to PY3, as indicated by the actual source file. * Migrate more libraries & first draft of direct pywheel rule usage in Bazel * Integrate with nanobind and libpfm * Make Python toolchain a dev dependency * Undo py_wheel usage until later * Added support for bzlmod for C++ parts of google_benchmark. * Make //tools:all buildable with --enable_bzlmod --------- Co-authored-by: Andy Christiansen <[email protected]>
1 parent 1d25c2e commit aacf2b1

7 files changed

+51
-12
lines changed

MODULE.bazel

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module(name = "com_github_google_benchmark", version="1.8.0")
2+
3+
bazel_dep(name = "bazel_skylib", version = "1.4.1")
4+
bazel_dep(name = "platforms", version = "0.0.6")
5+
bazel_dep(name = "rules_foreign_cc", version = "0.9.0")
6+
bazel_dep(name = "rules_cc", version = "0.0.6")
7+
bazel_dep(name = "rules_python", version = "0.23.1")
8+
bazel_dep(name = "googletest", version = "1.12.1", repo_name = "com_google_googletest")
9+
bazel_dep(name = "libpfm", version = "4.11.0")
10+
11+
# Register a toolchain for Python 3.9 to be able to build numpy. Python
12+
# versions >=3.10 are problematic.
13+
# A second reason for this is to be able to build Python hermetically instead
14+
# of relying on the changing default version from rules_python.
15+
16+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
17+
python.toolchain(python_version = "3.9")
18+
19+
# Extract the interpreter from the hermetic toolchain above, so we can use that
20+
# instead of the system interpreter for the pip compiplation step below.
21+
interpreter = use_extension("@rules_python//python/extensions:interpreter.bzl", "interpreter")
22+
interpreter.install(
23+
name = "interpreter",
24+
python_name = "python_3_9",
25+
)
26+
use_repo(interpreter, "interpreter")
27+
28+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
29+
pip.parse(
30+
name="tools_pip_deps",
31+
incompatible_generate_aliases = True,
32+
python_interpreter_target="@interpreter//:python",
33+
requirements_lock="//tools:requirements.txt")
34+
use_repo(pip, "tools_pip_deps")

WORKSPACE

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ rules_foreign_cc_dependencies()
1111
load("@rules_python//python:pip.bzl", pip3_install="pip_install")
1212

1313
pip3_install(
14-
name = "py_deps",
15-
requirements = "//:requirements.txt",
14+
name = "tools_pip_deps",
15+
requirements = "//tools:requirements.txt",
1616
)
1717

1818
new_local_repository(

WORKSPACE.bzlmod

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file marks the root of the Bazel workspace.
2+
# See MODULE.bazel for dependencies and setup.

docs/releasing.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@
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 the
12-
`__version__` variable in `bindings/python/google_benchmark/__init__.py`to the release
13-
version you're creating. (This version will be used if benchmark is installed from the
14-
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 the `__version__` variable in `bindings/python/google_benchmark/__init__.py`to the
13+
release version you're creating. (This version will be used if benchmark is installed
14+
from the archive you'll be creating in the next step.)
1515

1616
```
17-
project (benchmark VERSION 1.6.0 LANGUAGES CXX)
17+
project (benchmark VERSION 1.8.0 LANGUAGES CXX)
18+
```
19+
20+
```
21+
module(name = "com_github_google_benchmark", version="1.8.0")
1822
```
1923

2024
```python
2125
# bindings/python/google_benchmark/__init__.py
2226

2327
# ...
2428

25-
__version__ = "1.6.0" # <-- change this to the release version you are creating
29+
__version__ = "1.8.0" # <-- change this to the release version you are creating
2630

2731
# ...
2832
```

requirements.txt

-2
This file was deleted.

tools/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py_deps//:requirements.bzl", "requirement")
1+
load("@tools_pip_deps//:requirements.bzl", "requirement")
22

33
py_library(
44
name = "gbench",

tools/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
scipy>=1.5.0
1+
numpy == 1.25
2+
scipy == 1.5.4

0 commit comments

Comments
 (0)