“ py_binary”的作用是什么?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
制作某些可执行文件只能添加
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.