bazel-contrib / bazel-contrib/rules_python

exec tools exec_interpreter broken on RBE

Đang mở
#2,703 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
type: bug
Ngôn ngữ chính
Starlark
Star
688
Fork
721
Merge trung bình
15 giờ 7 phút
Pull request đã merge (30 ngày)
76

Mô tả

As found in https://github.com/bazel-contrib/rules_python/pull/2657, the `exec_interpreter` attribute of the exec tools toolchain doesn't work with RBE.

What happens is the `current_interpreter_executable()` helper rule does `declare_file(); symlink()`, which puts the file at e.g. `python/private/python3`. Locally, this creates a symlink and when run, Python follows the symlink back to the actual location of the installed runtime ("python home"); this works. On RBE, however, it creates copy of the file. Python then can't find its way back to "python home" and fails to find e.g. shared libs, stdlib, etc.

The intent of the `exec_interpreter` field was to make it easy to run an interpreter in a build action by having it support `DefaultInfo.files_to_run`, which lets it be passed directly to `ctx.actions.run(executable=...)`. Without a FilesToRun provider, the interpreter and its files have to be manually passed in. Additionally, because actions can't directly accept runfiles, it means the usual way to express the runfiles necessary for an executable (DefaultInfo.default_runfiles) can't be used.

-----

While looking into solutions, a promising option looked something like:
* Have py_runtime() return DefaultInfo with executable set.
* In order to do this, re-declare the interpreter file as a file. This, apparently, works, even if it "clobbers" the original file. This is necessary because DefaultInfo.executable requires the file to be produced by the same rule.
* In py_runtime_pair, have it put the DefaultInfo that py_runtime produced on the ToolchainInfo it returned
* Alternative: create a new PyRuntimeInfo with a replaced interpreter field

Consumers are then able to do e.g.

```
exe = ctx.toolchains["exec_tools"].interpreter # DefaultInfo.files_to_run object
```

Unfortunately, I didn't see a decent way to preserve the "exec_interpreter is a target that you can pass to ctx.actions.run" behavior. _Maybe_ this would be possible if the underlying py_runtime target (which would have DefaultInfo.executable) could be more directly plumbed though. I'm not sure that's possible, though.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách lần theo current_interpreter_executable() và đường đi của exec_interpreter qua py_runtime() và py_runtime_pair(). Kiểm tra cách DefaultInfo.files_to_run, DefaultInfo.executable và runfiles được cung cấp cho ctx.actions.run(executable=...). Hoàn thành khi một exec interpreter hoạt động dưới RBE mà vẫn giữ cách sử dụng executable trực tiếp như dự định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
build-system, infrastructure
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.