“ py_binary”的作用是什么?

发布于 2025-02-04 08:07:20 字数 67 浏览 1 评论 0原文

py_binary最终生成了PY脚本的可执行文件或别名?它的好处是什么?如果它是可执行文件,它将失去python的含义。

py_binary finally generates an executable file or an alias for a py script? What are its benefits? If it is an executable file, it will lose the meaning of python.

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

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

发布评论

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

评论(1

春庭雪 2025-02-11 08:07:20

制作某些可执行文件只能添加chmod +x并拍打#!/foo/bar line上方,事物本身仍然是以前的任何解释器代码。

对于Bazel,它将添加一个包装脚本,该脚本将在派遣到Python代码之前设置执行环境。考虑Bazel的Runfiles,以及其他py_library目标。

此外,您可以在需要可执行文件作为另一个目标的属性的地方使用目标。一个python文件没有任何依赖性依赖性,因此从技术上讲,这在那里很适合,但与Bazel无法很好地整合。

Making something executable can be just adding a chmod +x and slapping a #!/foo/bar line on top, the thing itself is still whatever interpreter code it was before.

In the case of bazel, it will add a wrapper script that will set up an execution environment before dispatching to the Python code. Consider e.g. Bazel's runfiles, but also other py_library targets.

In addition, you can use the target in places where an executable is required as attribute for another target. A single Python file doesn't have any dependencies Bazel knows about, so that would technically fit there but would not integrate well with Bazel.

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