Bazel 将 py_binary 输出复制到本地
如何将 bazel run 中生成的文件复制到 Bazel 中的本地目录?该文件在 ~/sample_repo/bazel-out/local-fastbuild/bin/gen_file.runfiles/sample_repo/some_dir/output.txt
中生成。我想将该文件复制到与本地构建文件相同的目录(例如 ~/sample_repo/output.txt
)以签入 VCS。下面是我的 BUILD 文件和 python 脚本。
构建
py_binary(
name = "gen_file",
srcs = ["gen_file.py"],
)
gen_file.py
with open('some_dir/output.txt', 'w+') as f:
f.write('some text')
How do I copy files generated in bazel run
to my local directory in Bazel? The file is generated in ~/sample_repo/bazel-out/local-fastbuild/bin/gen_file.runfiles/sample_repo/some_dir/output.txt
. I want to copy that file to the same directory as my BUILD file in local (eg. ~/sample_repo/output.txt
) for check in to VCS. Below are my BUILD file and the python script.
BUILD
py_binary(
name = "gen_file",
srcs = ["gen_file.py"],
)
gen_file.py
with open('some_dir/output.txt', 'w+') as f:
f.write('some text')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论