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

Migrate to Bzlmod for managing external dependencies #1204

Open
meteorcloudy opened this issue Oct 6, 2023 · 7 comments
Open

Migrate to Bzlmod for managing external dependencies #1204

meteorcloudy opened this issue Oct 6, 2023 · 7 comments

Comments

@meteorcloudy
Copy link
Member

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 bazelbuild/bazel#18958

@AttilaTheFun
Copy link
Contributor

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.

@meteorcloudy
Copy link
Member Author

@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?

@AttilaTheFun
Copy link
Contributor

AttilaTheFun commented Oct 23, 2023

@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).

@meteorcloudy
Copy link
Member Author

I see, that sounds doable. @vladmos is the main maintainer of buildtools, I assume he'll be happy to accept the contributions ;)

@AttilaTheFun
Copy link
Contributor

@meteorcloudy @vladmos FYI other people are requesting this on the bazelbuild/bazel-central-registry side too:
bazelbuild/bazel-central-registry#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.

@fardream
Copy link

fardream commented Feb 4, 2024

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.

fardream@51b8a3f

@dougthor42
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@fardream @AttilaTheFun @meteorcloudy @dougthor42 and others