Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rules): add build_data_file field to PyExecutableInfo #2181

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions python/private/common/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def _get_base_runfiles_for_binary(
* data_runfiles: The data runfiles
* runfiles_without_exe: The default runfiles, but without the executable
or files specific to the original program/executable.
* build_data_file: A file with build stamp information if stamping is enabled, otherwise None.
"""
common_runfiles_depsets = [main_py_files]

Expand Down Expand Up @@ -465,17 +466,21 @@ def _get_base_runfiles_for_binary(
data_runfiles = runfiles_with_exe

if is_stamping_enabled(ctx, semantics) and semantics.should_include_build_data(ctx):
default_runfiles = runfiles_with_exe.merge(_create_runfiles_with_build_data(
build_data_runfiles = _create_runfiles_with_build_data(
ctx,
semantics.get_central_uncachable_version_file(ctx),
semantics.get_extra_write_build_data_env(ctx),
))
)
build_data_file = build_data_runfiles.symlinks.to_list()[0].target_file
oprypin marked this conversation as resolved.
Show resolved Hide resolved
default_runfiles = runfiles_with_exe.merge(build_data_runfiles)
else:
build_data_file = None
default_runfiles = runfiles_with_exe

return struct(
runfiles_without_exe = common_runfiles,
default_runfiles = default_runfiles,
build_data_file = build_data_file,
data_runfiles = data_runfiles,
)

Expand Down Expand Up @@ -829,6 +834,7 @@ def _create_providers(
PyExecutableInfo(
main = main_py,
runfiles_without_exe = runfiles_details.runfiles_without_exe,
build_data_file = runfiles_details.build_data_file,
interpreter_path = runtime_details.executable_interpreter_path,
),
]
Expand Down
5 changes: 5 additions & 0 deletions python/private/py_executable_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ This provider is for executable-specific information (e.g. tests and binaries).
:::
""",
fields = {
"build_data_file": """
:type: File
oprypin marked this conversation as resolved.
Show resolved Hide resolved

A symlink to build_data.txt if stamping is enabled, otherwise None.
""",
"interpreter_path": """
:type: None | str

Expand Down