Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for bzlmod (excluding Python bindings) #1615

Merged
merged 12 commits into from
Jun 27, 2023
34 changes: 34 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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")
macandy13 marked this conversation as resolved.
Show resolved Hide resolved

# 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")
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
dmah42 marked this conversation as resolved.
Show resolved Hide resolved
)

new_local_repository(
Expand Down
2 changes: 2 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file marks the root of the Bazel workspace.
macandy13 marked this conversation as resolved.
Show resolved Hide resolved
# See MODULE.bazel for dependencies and setup.
16 changes: 10 additions & 6 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@
* `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
# bindings/python/google_benchmark/__init__.py

# ...

__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

# ...
```
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@py_deps//:requirements.bzl", "requirement")
load("@tools_pip_deps//:requirements.bzl", "requirement")

py_library(
name = "gbench",
Expand Down
3 changes: 2 additions & 1 deletion tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
scipy>=1.5.0
numpy == 1.25
scipy == 1.5.4