-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
P2We'll consider working on this in future. (Assignee optional)We'll consider working on this in future. (Assignee optional)area-BzlmodBzlmod-specific PRs, issues, and feature requestsBzlmod-specific PRs, issues, and feature requeststeam-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.External dependency handling, remote repositiories, WORKSPACE file.type: feature request
Description
Description of the feature request:
Allow a module extension to return a value:
my_extension = use_extension(...)
value = my_extension.my_function(...)
# do something with value
What underlying problem are you trying to solve with this feature?
If a module extension returns a large number of git repositories, it becomes infeasible to use_repo on each one individually.
Here's an example:
bazel_dep(name = "gazelle", version = "0.27.0")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps,
"com_github_gogo_protobuf",
...
)
In this example, we need to specify the dependencies once in the go.mod file, and once again in the MODULE.bazel file. I've tested, and the following does appear to work:
bazel_dep(name = "gazelle", version = "0.27.0")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
GO_REPOS = ["com_github_gogo_protobuf", ...]
use_repo(go_deps, *GO_REPOS)
Would it be possible to support the following:
bazel_dep(name = "gazelle", version = "0.27.0")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_repos = go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, *go_repos)
This would allow go.mod to be our source of truth for go repositories (and would allow other languages to do the same).
Which operating system are you running Bazel on?
Linux
What is the output of bazel info release?
release 6.0.0-pre.20221012.2
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?
N/A (using repo tool, many repos)
Have you found anything relevant by searching the web?
Python appears to take an alternative approach where they write every package to a single repository. This would be a theoretically possible alternative, but:
- go has historically used one repo per package, and this would make it much harder to upgrade existing go repositories to bzlmod
- I assume other languages may have similar issues
- I tried writing a repo_rule for rust recently which did a similar thing, and it's much simpler to work with one package per repository
- Depending on how this was implemented in bazel, there may be degraded performance for putting all things in a single repository, including potentially:
- Unable to do a partial download if you only depend upon some of the things declared by the module extension
- Unable to download these repos in parallel
- A change to one package version could result in having to re-download every one.
Any other information, logs, or outputs that you want to share?
No response
Metadata
Metadata
Assignees
Labels
P2We'll consider working on this in future. (Assignee optional)We'll consider working on this in future. (Assignee optional)area-BzlmodBzlmod-specific PRs, issues, and feature requestsBzlmod-specific PRs, issues, and feature requeststeam-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.External dependency handling, remote repositiories, WORKSPACE file.type: feature request