【发布时间】:2023-03-31 13:59:01
【问题描述】:
当我从 bazel genrule 运行一个使用“sh”模块的 python 脚本时,它失败了:
INFO: Analysed target //src:foo_gen (8 packages loaded).
INFO: Found 1 target...
ERROR: /home/libin11/workspace/test/test/src/BUILD:1:1: Executing genrule //src:foo_gen failed (Exit 1)
Traceback (most recent call last):
File "src/test.py", line 2, in <module>
sh.touch("foo.bar")
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1427, in __call__
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 767, in __init__
self.call_args, pipe, process_assign_lock)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1784, in __init__
self._stdout_read_fd, self._stdout_write_fd = pty.openpty()
File "/usr/lib/python2.7/pty.py", line 29, in openpty
master_fd, slave_name = _open_terminal()
File "/usr/lib/python2.7/pty.py", line 70, in _open_terminal
raise os.error, 'out of pty devices'
OSError: out of pty devices
Target //src:foo_gen failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.143s, Critical Path: 0.12s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
我想将第三方项目集成到我自己的项目中。第三方项目是用python脚本构建的,所以我想用bazel genrule构建项目。
这是一个示例文件列表:
.
├── src
│ ├── BUILD
│ └── test.py
└── WORKSPACE
WORKSPACE 为空,BUILD 为:
genrule(
name = "foo_gen",
srcs = glob(["**/*"]),
outs = ["foo.bar"],
cmd = "python $(location test.py)",
)
test.py 是:
import sh
sh.touch("foo.bar")
然后运行:
bazel build //src:foo_gen
操作系统:Ubuntu 16.04 bazel:发布 0.14.1
【问题讨论】: