Skip to content

Commit

Permalink
upgrade Bazel to use bzlmod
Browse files Browse the repository at this point in the history
WORKSPACE without bzlmod has been deprecated
  • Loading branch information
grische committed Dec 2, 2024
1 parent 6612d76 commit 6b12438
Show file tree
Hide file tree
Showing 8 changed files with 531 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enable Bzlmod for every Bazel command
common --enable_bzlmod
8 changes: 8 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_python//python:pip.bzl", "compile_pip_requirements")

compile_pip_requirements(
name = "requirements",
src = "//:requirements.txt",
requirements_txt = "requirements_lock.txt",
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM gcr.io/bazel-public/bazel:7.4.1 AS builder

WORKDIR /wgkex

COPY BUILD WORKSPACE requirements.txt ./
COPY .bazelrc BUILD MODULE.bazel MODULE.bazel.lock requirements_lock.txt ./
COPY wgkex ./wgkex

RUN ["bazel", "build", "//wgkex/broker:app"]
Expand Down
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bazel_dep(name = "rules_python", version = "0.40.0")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

pip.parse(
hub_name = "pip",
python_version = "3.11",
requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
255 changes: 255 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ python3 -c 'from wgkex.worker.app import main; main()'

## Development

### Updating PIP dependencies

This package is using Bazel's `compile_pip_requirements` to get a requirements_lock.txt file.
In order to update the respective depencencies after modifying the requirements.txt, run:

```sh
bazel run //:requirements.update
```

### Unit tests

The test can be run using `bazel test ... --test_output=all` or `python3 -m unittest discover -p '*_test.py'`.
Expand Down
14 changes: 0 additions & 14 deletions WORKSPACE

This file was deleted.

245 changes: 245 additions & 0 deletions requirements_lock.txt

Large diffs are not rendered by default.

0 comments on commit 6b12438

Please sign in to comment.