buildtools
buildtools copied to clipboard
Migrate to Bzlmod for managing external dependencies
With future Bazel LTS versions, Bzlmod will become the default system for external dependencies management.
Please consider migrating all your external dependencies in WORKSPACE to MODULE.bazel
For more information, please check https://github.com/bazelbuild/bazel/issues/18958
I would love to use this repo through a Bazel module as well! I use Bazel modules and I had to write my own module extension to load it as an http_archive which is a hassle. I would be open to helping with the migration if there are any well scoped tasks I could take on.
@AttilaTheFun This issue is more about migrating buildtools to be built and tested with external deps fetched from Bzlmod. Do you mean you want to buildtools as an external dependency? Can you explain a bit about why you need to do that?
@meteorcloudy I know you can install buildifier and buildozer as prebuilt binaries, but I much prefer to add them as bazel dependencies and build from source.
This is especially useful if I want to use forked copy of the repo while waiting for changes to be merged upstream. I also don't need to worry about selecting the right binary for use on the machine (macos arm vs intel, linux on ci).
I see, that sounds doable. @vladmos is the main maintainer of buildtools, I assume he'll be happy to accept the contributions ;)
@meteorcloudy @vladmos FYI other people are requesting this on the bazelbuild/bazel-central-registry side too: https://github.com/bazelbuild/bazel-central-registry/issues/380 I'm not sure what providing a Bazel module requires beyond adding a MODULE.bazel file to the repository. If I had a more concrete understanding of what the remaining issues are, I could possibly help out.
I tried and took a stab at adding support, but the check on the generated proto files fails due to the version mismatch between protoc-gen-go and protoc. Bazel central registry doesn't have 24.4 or latest protobuf yet. Otherwise it looks to be working fine.
https://github.com/fardream/buildtools/commit/51b8a3f3ad767a4b91b0f160263eb11d14b05c98
For the record, there's an unofficial repo that allows setting up buildifier via MODULE.bazel: https://github.com/keith/buildifier-prebuilt
Example:
# MODULE.bazel
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
# ./BUILD
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
buildifier(
name = "buildifier.check",
exclude_patterns = [
"./.git/*",
],
lint_mode = "warn",
mode = "diff",
)
$ bazel run -- //:buildifier.check
INFO: Analyzed target //:buildifier.check (68 packages loaded, 343 targets configured).
INFO: Found 1 target...
Target //:buildifier.check up-to-date:
bazel-bin/buildifier.check.bash
INFO: Elapsed time: 0.387s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/buildifier.check.bash
./tests/BUILD:
--- ./tests/BUILD 2024-02-20 20:26:07.852510800 -0800
+++ /tmp/buildifier-tmp-1708334010 2024-02-20 20:26:09.836148000 -0800
@@ -4,8 +4,8 @@
py_library(
name = "__init__",
- deps = [],
srcs = ["__init__.py"],
+ deps = [],
)
py_library(
exit status 1