Skip to content

Commit

Permalink
Merge pull request #156 from grische/migrate-to-bzlmod
Browse files Browse the repository at this point in the history
Migrate to bzlmod
  • Loading branch information
grische authored Dec 10, 2024
2 parents 6612d76 + 95c0ff9 commit d049215
Show file tree
Hide file tree
Showing 8 changed files with 3,623 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
15 changes: 15 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bazel_dep(name = "rules_python", version = "1.0.0-rc2")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
python_version = "3.13",
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = "3.13",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pip")
3,343 changes: 3,343 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 d049215

Please sign in to comment.