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

cleanup: Remove uses of legacy struct providers #1812

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 4 additions & 10 deletions python/private/common/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment =
data_runfiles = runfiles_details.data_runfiles.merge(extra_exec_runfiles),
)

legacy_providers, modern_providers = _create_providers(
return _create_providers(
ctx = ctx,
executable = executable,
runfiles_details = runfiles_details,
Expand All @@ -197,10 +197,6 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment =
semantics = semantics,
output_groups = exec_result.output_groups,
)
return struct(
legacy_providers = legacy_providers,
providers = modern_providers,
)

def _get_build_info(ctx, cc_toolchain):
build_info_files = py_internal.cc_toolchain_build_info_files(cc_toolchain)
Expand Down Expand Up @@ -749,9 +745,7 @@ def _create_providers(
semantics: BinarySemantics struct; see create_binary_semantics()

Returns:
A two-tuple of:
1. A dict of legacy providers.
2. A list of modern providers.
A list of modern providers.
"""
providers = [
DefaultInfo(
Expand Down Expand Up @@ -821,13 +815,13 @@ def _create_providers(
providers.append(builtin_py_info)
providers.append(create_output_group_info(py_info.transitive_sources, output_groups))

extra_legacy_providers, extra_providers = semantics.get_extra_providers(
extra_providers = semantics.get_extra_providers(
ctx,
main_py = main_py,
runtime_details = runtime_details,
)
providers.extend(extra_providers)
return extra_legacy_providers, providers
return providers

def _create_run_environment_info(ctx, inherited_environment):
expanded_env = {}
Expand Down
8 changes: 2 additions & 6 deletions python/private/common/py_executable_bazel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,12 @@ def create_executable_rule(*, attrs, **kwargs):

def py_executable_bazel_impl(ctx, *, is_test, inherited_environment):
"""Common code for executables for Bazel."""
result = py_executable_base_impl(
return py_executable_base_impl(
ctx = ctx,
semantics = create_binary_semantics_bazel(),
is_test = is_test,
inherited_environment = inherited_environment,
)
return struct(
providers = result.providers,
**result.legacy_providers
)

def create_binary_semantics_bazel():
return create_binary_semantics_struct(
Expand Down Expand Up @@ -143,7 +139,7 @@ def _get_debugger_deps(ctx, runtime_details):

def _get_extra_providers(ctx, main_py, runtime_details):
_ = ctx, main_py, runtime_details # @unused
return {}, []
return []

def _get_stamp_flag(ctx):
# NOTE: Undocumented API; private to builtins
Expand Down
2 changes: 1 addition & 1 deletion python/private/common/py_test_rule_bazel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _py_test_impl(ctx):
is_test = True,
inherited_environment = ctx.attr.env_inherit,
)
maybe_add_test_execution_info(providers.providers, ctx)
maybe_add_test_execution_info(providers, ctx)
return providers

py_test = create_executable_rule(
Expand Down
Loading