Bazel查询以列出目标的所有依赖关系以及依赖项的版本

发布于 2025-02-07 22:36:37 字数 157 浏览 2 评论 0原文

寻找一种方法,以获取目标依赖项的所有外部依赖项列表(在构建文件中定义)。

bazel Query“ Kind(规则,deps(// foo:target))” - 输出=软件包 仅返回依赖项列表。

有没有办法记录依赖关系:构建过程中的版本?

looking for a way to get list of all external dependencies along with the version (defined in build file) of the dependencies for the target.

bazel query "kind(rule, deps(//foo:target))" --output=package
only returns list of dependencies.

is there a way to log dependency:version during the build?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2025-02-14 22:36:37

这可能取决于您正在使用的Bazel Python规则的版本,但是我们使用类似的查询,因此以获取具有其名称和版本的格式的

bazel query "deps(kind(rule, deps(//foo:target)))"

deps

@requirements_werkzeug_3_0_1_py3_none_any_whl//file:werkzeug-3.0.1-py3-none-any.whl

。 :本质上是文件名和软件包。有一点狂欢,我基本上可以得到您

bazel query "deps(kind(rule, deps(//foo:target)))" | \
  grep whl | grep -v "file:file" | \
  cut -d ":" -f2 | cut -d"-" -f1-2 | tr "-" ":"

产生看起来像的输出的东西

werkzeug:3.0.1

This might depend on the version of the bazel python rules you're using, but we use a query like so just to get deps in the format that have their name and version

bazel query "deps(kind(rule, deps(//foo:target)))"

This produces output that contains lines like

@requirements_werkzeug_3_0_1_py3_none_any_whl//file:werkzeug-3.0.1-py3-none-any.whl

The bit after the : is essentially the filename and the package. With a bit of bash I can get basically what you're after

bazel query "deps(kind(rule, deps(//foo:target)))" | \
  grep whl | grep -v "file:file" | \
  cut -d ":" -f2 | cut -d"-" -f1-2 | tr "-" ":"

Which produces output that looks like

werkzeug:3.0.1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文