@@ -940,7 +940,7 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment =
940
940
941
941
imports = collect_imports (ctx , semantics )
942
942
943
- runtime_details = _get_runtime_details (ctx , semantics , is_test )
943
+ runtime_details = _get_runtime_details (ctx , semantics )
944
944
if ctx .configuration .coverage_enabled :
945
945
extra_deps = semantics .get_coverage_deps (ctx , runtime_details )
946
946
else :
@@ -1040,7 +1040,7 @@ def _declare_executable_file(ctx):
1040
1040
1041
1041
return executable
1042
1042
1043
- def _get_runtime_details (ctx , semantics , is_test ):
1043
+ def _get_runtime_details (ctx , semantics ):
1044
1044
"""Gets various information about the Python runtime to use.
1045
1045
1046
1046
While most information comes from the toolchain, various legacy and
@@ -1049,7 +1049,6 @@ def _get_runtime_details(ctx, semantics, is_test):
1049
1049
Args:
1050
1050
ctx: Rule ctx
1051
1051
semantics: A `BinarySemantics` struct; see `create_binary_semantics_struct`
1052
- is_test: bool; True if the rule is a test rule (has `test=True`), False if not
1053
1052
1054
1053
Returns:
1055
1054
A struct; see inline-field comments of the return value for details.
@@ -1078,7 +1077,6 @@ def _get_runtime_details(ctx, semantics, is_test):
1078
1077
if not effective_runtime :
1079
1078
fail ("Unable to find Python runtime" )
1080
1079
1081
- extra_test_env = {}
1082
1080
if effective_runtime :
1083
1081
direct = [] # List of files
1084
1082
transitive = [] # List of depsets
@@ -1091,12 +1089,6 @@ def _get_runtime_details(ctx, semantics, is_test):
1091
1089
direct .append (effective_runtime .coverage_tool )
1092
1090
if effective_runtime .coverage_files :
1093
1091
transitive .append (effective_runtime .coverage_files )
1094
- if is_test :
1095
- py_test_toolchain = ctx .exec_groups ["test" ].toolchains [PY_TEST_TOOLCHAIN_TYPE ]
1096
- if py_test_toolchain :
1097
- coverage_rc = py_test_toolchain .py_test_info .coverage_rc
1098
- extra_test_env = {"COVERAGE_RC" : coverage_rc .files .to_list ()[0 ].short_path }
1099
- direct .extend (coverage_rc .files .to_list ())
1100
1092
runtime_files = depset (direct = direct , transitive = transitive )
1101
1093
else :
1102
1094
runtime_files = depset ()
@@ -1128,9 +1120,6 @@ def _get_runtime_details(ctx, semantics, is_test):
1128
1120
# be included. For in-build runtimes, this shold include the interpreter
1129
1121
# and any supporting files.
1130
1122
runfiles = ctx .runfiles (transitive_files = runtime_files ),
1131
- # extra_test_env: dict[str, str]; Additional environment variables to
1132
- # set when running the test.
1133
- extra_test_env = extra_test_env ,
1134
1123
)
1135
1124
1136
1125
def _maybe_get_runtime_from_ctx (ctx ):
@@ -1626,22 +1615,8 @@ def _create_providers(
1626
1615
Returns:
1627
1616
A list of modern providers.
1628
1617
"""
1629
-
1630
1618
providers = [
1631
- DefaultInfo (
1632
- executable = executable ,
1633
- files = default_outputs ,
1634
- default_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
1635
- ctx ,
1636
- runfiles_details .default_runfiles ,
1637
- ),
1638
- data_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
1639
- ctx ,
1640
- runfiles_details .data_runfiles ,
1641
- ),
1642
- ),
1643
1619
create_instrumented_files_info (ctx ),
1644
- _create_run_environment_info (ctx , inherited_environment , runtime_details .extra_test_env ),
1645
1620
PyExecutableInfo (
1646
1621
main = main_py ,
1647
1622
runfiles_without_exe = runfiles_details .runfiles_without_exe ,
@@ -1712,9 +1687,22 @@ def _create_providers(
1712
1687
runtime_details = runtime_details ,
1713
1688
)
1714
1689
providers .extend (extra_providers )
1715
- return providers
1690
+ environemnt_info = _create_run_environment_info (ctx , inherited_environment )
1691
+ binary_info = struct (
1692
+ executable = executable ,
1693
+ files = default_outputs ,
1694
+ default_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
1695
+ ctx ,
1696
+ runfiles_details .default_runfiles ,
1697
+ ),
1698
+ data_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
1699
+ ctx ,
1700
+ runfiles_details .data_runfiles ,
1701
+ ),
1702
+ )
1703
+ return providers , binary_info , environemnt_info
1716
1704
1717
- def _create_run_environment_info (ctx , inherited_environment , extra_test_env ):
1705
+ def _create_run_environment_info (ctx , inherited_environment ):
1718
1706
expanded_env = {}
1719
1707
for key , value in ctx .attr .env .items ():
1720
1708
expanded_env [key ] = _py_builtins .expand_location_and_make_variables (
@@ -1723,8 +1711,7 @@ def _create_run_environment_info(ctx, inherited_environment, extra_test_env):
1723
1711
expression = value ,
1724
1712
targets = ctx .attr .data ,
1725
1713
)
1726
- expanded_env .update (extra_test_env )
1727
- return RunEnvironmentInfo (
1714
+ return struct (
1728
1715
environment = expanded_env ,
1729
1716
inherited_environment = inherited_environment ,
1730
1717
)
0 commit comments