diff --git a/python/private/common.bzl b/python/private/common.bzl index 2d4afca3f5..527fbc5c7d 100644 --- a/python/private/common.bzl +++ b/python/private/common.bzl @@ -109,27 +109,6 @@ def create_cc_details_struct( **kwargs ) -def create_executable_result_struct(*, extra_files_to_build, output_groups, extra_runfiles = None): - """Creates a `CreateExecutableResult` struct. - - This is the return value type of the semantics create_executable function. - - Args: - extra_files_to_build: depset of File; additional files that should be - included as default outputs. - output_groups: dict[str, depset[File]]; additional output groups that - should be returned. - extra_runfiles: A runfiles object of additional runfiles to include. - - Returns: - A `CreateExecutableResult` struct. - """ - return struct( - extra_files_to_build = extra_files_to_build, - output_groups = output_groups, - extra_runfiles = extra_runfiles, - ) - def csv(values): """Convert a list of strings to comma separated value string.""" return ", ".join(sorted(values)) diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index 8b28b4ffae..2ecc88b720 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -42,7 +42,6 @@ load( "collect_runfiles", "create_binary_semantics_struct", "create_cc_details_struct", - "create_executable_result_struct", "create_instrumented_files_info", "create_output_group_info", "create_py_info", @@ -377,7 +376,7 @@ def _create_executable( runfiles = runfiles_details.runfiles_without_exe.merge(extra_runfiles), ) - extra_files_to_build = [] + extra_default_outputs = [] # NOTE: --build_python_zip defaults to true on Windows build_zip_enabled = read_possibly_native_flag(ctx, "build_python_zip") @@ -385,7 +384,7 @@ def _create_executable( # When --build_python_zip is enabled, then the zip file becomes # one of the default outputs. if build_zip_enabled: - extra_files_to_build.append(zip_file) + extra_default_outputs.append(zip_file) # The logic here is a bit convoluted. Essentially, there are 3 types of # executables produced: @@ -417,7 +416,7 @@ def _create_executable( # The launcher looks for the non-zip executable next to # itself, so add it to the default outputs. - extra_files_to_build.append(bootstrap_output) + extra_default_outputs.append(bootstrap_output) if should_create_executable_zip: if bootstrap_output != None: @@ -459,9 +458,14 @@ def _create_executable( # added to the zipped files. if venv and venv.interpreter: extra_runfiles = extra_runfiles.merge(ctx.runfiles([venv.interpreter])) - return create_executable_result_struct( - extra_files_to_build = depset(extra_files_to_build), + return struct( + # depset[File] of additional files that should be included as default + # outputs. + extra_default_outputs = depset(extra_default_outputs), + # dict[str, depset[File]]; additional output groups that should be + # returned. output_groups = {"python_zip_file": depset([zip_file])}, + # runfiles; additional runfiles to include. extra_runfiles = extra_runfiles, ) @@ -1078,10 +1082,10 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment = runfiles_details = runfiles_details, extra_deps = extra_deps, ) - default_outputs.add(exec_result.extra_files_to_build) + default_outputs.add(exec_result.extra_default_outputs) extra_exec_runfiles = exec_result.extra_runfiles.merge( - ctx.runfiles(transitive_files = exec_result.extra_files_to_build), + ctx.runfiles(transitive_files = exec_result.extra_default_outputs), ) # Copy any existing fields in case of company patches. diff --git a/tests/base_rules/py_executable_base_tests.bzl b/tests/base_rules/py_executable_base_tests.bzl index 83a470cdc5..49d5f49b86 100644 --- a/tests/base_rules/py_executable_base_tests.bzl +++ b/tests/base_rules/py_executable_base_tests.bzl @@ -377,7 +377,7 @@ def _test_explicit_main_cannot_be_ambiguous_impl(env, target): matching.str_matches("foo.py*matches multiple"), ) -def _test_files_to_build(name, config): +def _test_default_outputs(name, config): rt_util.helper_target( config.rule, name = name + "_subject", @@ -385,14 +385,14 @@ def _test_files_to_build(name, config): ) analysis_test( name = name, - impl = _test_files_to_build_impl, + impl = _test_default_outputs_impl, target = name + "_subject", attrs = WINDOWS_ATTR, ) -_tests.append(_test_files_to_build) +_tests.append(_test_default_outputs) -def _test_files_to_build_impl(env, target): +def _test_default_outputs_impl(env, target): default_outputs = env.expect.that_target(target).default_outputs() if pt_util.is_windows(env): default_outputs.contains("{package}/{test_name}_subject.exe") diff --git a/tests/base_rules/py_library/py_library_tests.bzl b/tests/base_rules/py_library/py_library_tests.bzl index 9b585b17ef..3726ff1f41 100644 --- a/tests/base_rules/py_library/py_library_tests.bzl +++ b/tests/base_rules/py_library/py_library_tests.bzl @@ -27,7 +27,7 @@ def _test_py_runtime_info_not_present_impl(env, target): _tests.append(_test_py_runtime_info_not_present) -def _test_files_to_build(name, config): +def _test_default_outputs(name, config): rt_util.helper_target( config.rule, name = name + "_subject", @@ -36,15 +36,15 @@ def _test_files_to_build(name, config): analysis_test( name = name, target = name + "_subject", - impl = _test_files_to_build_impl, + impl = _test_default_outputs_impl, ) -def _test_files_to_build_impl(env, target): +def _test_default_outputs_impl(env, target): env.expect.that_target(target).default_outputs().contains_exactly([ "{package}/lib.py", ]) -_tests.append(_test_files_to_build) +_tests.append(_test_default_outputs) def _test_srcs_can_contain_rule_generating_py_and_nonpy_files(name, config): rt_util.helper_target(