Surfacing all bootstrap runfiles in PyExecutableInfo
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- build-system
Hướng nghiên cứu
Đọc python/private/py_executable.bzl và python/private/py_executable_info.bzl, bắt đầu từ _create_providers và đường dẫn files_without_interpreter hiện có. Theo dõi cách stage2 bootstrap và các tệp venv đi tới app_runfiles, sau đó xác minh rằng trường runfiles được chọn được cung cấp cho py_binary và py_test và được lập tài liệu cho người dùng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🚀 feature request
Relevant Rules
Adding a runfile object containing all "runfiles" of the (stage2) bootstrappers to PyExecutableInfo (impacts py_binary, py_test).
Description
We have a custom collect_layers rule that takes a py_binary and produces different output groups that map to different layers in an OCI image that will be built in downstream rules. Most of this is captured by PyRuntimeInfo (for the interpreter) and PyExecutableInfo.app_runfiles - however, we would like to split 3rd party deps/runfiles (from PyPI) and our own code into different layers for optimization. At the moment, we are effectively rebuilding similar depsets to app_runfiles but are doing so via an aspect that traverses the build graph in order to do so efficiently without flattening the depset.
https://github.com/bazel-contrib/rules_python/issues/3324 added extra fields to identify the stage2_bootstrap, but additional files required by the stage2 bootstrapper to work correctly (like the venv site-packages files venv _bazel_site_init.pth and bazel_site_init.py) are still only surfaced via the PyExecutableInfo.app_runfiles - this makes it impossible to add them to my output groups without flattening that depset which is not desirable.
Describe the solution you'd like
It would be great if PyExecutableInfo could return a stage2_runfiles (for stage2 specifically) or bootstrap_runfiles (for all bootstrap-related files) fields which includes any additional runfiles it needs.
Describe alternatives you've considered
At the moment, these "extra runfiles" are already modeled somewhat in code under files_without_interpreter, we just surface them via a targeted patch of the provider like so:
# This patch is for rules_python 1.9.0, as of time of writing
diff --git python/private/py_executable.bzl python/private/py_executable.bzl
index 284aea6b..95bb4676 100644
--- python/private/py_executable.bzl
+++ python/private/py_executable.bzl
@@ -491,6 +491,7 @@ WARNING: Target: {}
app_runfiles = app_runfiles.build(ctx),
# File|None; the venv `bin/python3` file, if any.
venv_python_exe = venv.interpreter if venv else None,
+ files_without_interpreter = venv.files_without_interpreter if venv else None,
)
def _create_zip_main(ctx, *, stage2_bootstrap, runtime_details, venv):
@@ -1094,6 +1095,7 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment =
app_runfiles = app_runfiles,
venv_python_exe = exec_result.venv_python_exe,
interpreter_args = ctx.attr.interpreter_args,
+ files_without_interpreter = exec_result.files_without_interpreter,
)
def _get_build_info(ctx, cc_toolchain):
@@ -1639,7 +1641,8 @@ def _create_providers(
stage2_bootstrap,
app_runfiles,
venv_python_exe,
- interpreter_args):
+ interpreter_args,
+ files_without_interpreter):
"""Creates the providers an executable should return.
Args:
@@ -1700,6 +1703,7 @@ def _create_providers(
app_runfiles = app_runfiles,
venv_python_exe = venv_python_exe,
interpreter_args = interpreter_args,
+ files_without_interpreter = files_without_interpreter,
),
]
diff --git python/private/py_executable_info.bzl python/private/py_executable_info.bzl
index defbd3a0..c1b7592a 100644
--- python/private/py_executable_info.bzl
+++ python/private/py_executable_info.bzl
@@ -87,5 +87,6 @@ mode is not enabled.
:::{versionadded} 1.9.0
:::
""",
+ "files_without_interpreter": "Extra files required by the stage2 bootstrapper",
},
)
At the moment, we are still relying on bootstrap_impl=system_python (but "hack" the shebang to point to the interpreter in runfiles - this is the very first layer in the image before the other two).
I believe that the venv/bin/python3 symlink is also required for the stage1 bootstrap if one were to use bootstrap_impl=script - if so, it might be nicer to model this as a a generic bootstrap_runfiles field in which all bootstrap runfiles could live (so everything under venv and the stage2 bootstrap file itself)?
- Ngôn ngữ chính
- Starlark
- Star
- 690
- Fork
- 722
- Merge trung bình
- 1 ngày 55 phút
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bazel-contrib/rules_python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
bazel-contrib/rules_python#4179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bazel-contrib/rules_python#4164 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bazel-contrib/rules_python#3821 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
bazel-contrib/rules_python#4181 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Release 2.4.0Đang mởtype: release
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
bazel-contrib/rules_python#4175 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của bazel-contrib/rules_python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
opengovsg/FormSG#10118 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support git worktreesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
block/artifact-swap#176 ·
-
area:lint-tooling bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
InauguralSystems/EigenScript#1340 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ADR-0001, ADR-0002, ADR-0003Đang mởadr part:1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
tiarebalbi/bullpen#3 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 4 ngày