aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Christiansen <andy.christ79@gmail.com>2023-06-27 14:03:39 +0200
committerGitHub <noreply@github.com>2023-06-27 13:03:39 +0100
commitaacf2b1af967b083565be8c7181626b4609318ac (patch)
treebcd5d81f21ae40a03921583bd2d78264f57ab7cf
parent1d25c2e3bea73ea03592abc7e7ef9b6a47c2e90b (diff)
downloadgoogle-benchmark-aacf2b1af967b083565be8c7181626b4609318ac.tar.gz
Add support for bzlmod (excluding Python bindings) (#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 <achristiansen@google.com>
-rw-r--r--MODULE.bazel34
-rw-r--r--WORKSPACE4
-rw-r--r--WORKSPACE.bzlmod2
-rw-r--r--docs/releasing.md16
-rw-r--r--requirements.txt2
-rw-r--r--tools/BUILD.bazel2
-rw-r--r--tools/requirements.txt3
7 files changed, 51 insertions, 12 deletions
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 0000000..0337ccc
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,34 @@
+module(name = "com_github_google_benchmark", version="1.8.0")
+
+bazel_dep(name = "bazel_skylib", version = "1.4.1")
+bazel_dep(name = "platforms", version = "0.0.6")
+bazel_dep(name = "rules_foreign_cc", version = "0.9.0")
+bazel_dep(name = "rules_cc", version = "0.0.6")
+bazel_dep(name = "rules_python", version = "0.23.1")
+bazel_dep(name = "googletest", version = "1.12.1", repo_name = "com_google_googletest")
+bazel_dep(name = "libpfm", version = "4.11.0")
+
+# Register a toolchain for Python 3.9 to be able to build numpy. Python
+# versions >=3.10 are problematic.
+# A second reason for this is to be able to build Python hermetically instead
+# of relying on the changing default version from rules_python.
+
+python = use_extension("@rules_python//python/extensions:python.bzl", "python")
+python.toolchain(python_version = "3.9")
+
+# Extract the interpreter from the hermetic toolchain above, so we can use that
+# instead of the system interpreter for the pip compiplation step below.
+interpreter = use_extension("@rules_python//python/extensions:interpreter.bzl", "interpreter")
+interpreter.install(
+ name = "interpreter",
+ python_name = "python_3_9",
+)
+use_repo(interpreter, "interpreter")
+
+pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
+pip.parse(
+ name="tools_pip_deps",
+ incompatible_generate_aliases = True,
+ python_interpreter_target="@interpreter//:python",
+ requirements_lock="//tools:requirements.txt")
+use_repo(pip, "tools_pip_deps")
diff --git a/WORKSPACE b/WORKSPACE
index 74e7ebc..833590f 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -11,8 +11,8 @@ rules_foreign_cc_dependencies()
load("@rules_python//python:pip.bzl", pip3_install="pip_install")
pip3_install(
- name = "py_deps",
- requirements = "//:requirements.txt",
+ name = "tools_pip_deps",
+ requirements = "//tools:requirements.txt",
)
new_local_repository(
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
new file mode 100644
index 0000000..9526376
--- /dev/null
+++ b/WORKSPACE.bzlmod
@@ -0,0 +1,2 @@
+# This file marks the root of the Bazel workspace.
+# See MODULE.bazel for dependencies and setup.
diff --git a/docs/releasing.md b/docs/releasing.md
index 6d3b613..cdf4159 100644
--- a/docs/releasing.md
+++ b/docs/releasing.md
@@ -8,13 +8,17 @@
* `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` 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.)
+* Create one last commit that updates the version saved in `CMakeLists.txt`, `MODULE.bazel`
+ 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.6.0 LANGUAGES CXX)
+project (benchmark VERSION 1.8.0 LANGUAGES CXX)
+```
+
+```
+module(name = "com_github_google_benchmark", version="1.8.0")
```
```python
@@ -22,7 +26,7 @@ project (benchmark VERSION 1.6.0 LANGUAGES CXX)
# ...
-__version__ = "1.6.0" # <-- change this to the release version you are creating
+__version__ = "1.8.0" # <-- change this to the release version you are creating
# ...
```
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index 1c8a4bd..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-numpy == 1.22
-scipy == 1.5.4
diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel
index c0cbc64..d25caa7 100644
--- a/tools/BUILD.bazel
+++ b/tools/BUILD.bazel
@@ -1,4 +1,4 @@
-load("@py_deps//:requirements.bzl", "requirement")
+load("@tools_pip_deps//:requirements.bzl", "requirement")
py_library(
name = "gbench",
diff --git a/tools/requirements.txt b/tools/requirements.txt
index 3b3331b..afbc596 100644
--- a/tools/requirements.txt
+++ b/tools/requirements.txt
@@ -1 +1,2 @@
-scipy>=1.5.0 \ No newline at end of file
+numpy == 1.25
+scipy == 1.5.4