59
59
load (
60
60
":toolchain_types.bzl" ,
61
61
"EXEC_TOOLS_TOOLCHAIN_TYPE" ,
62
- "PY_TEST_TOOLCHAIN_TYPE" ,
63
62
TOOLCHAIN_TYPE = "TARGET_TOOLCHAIN_TYPE" ,
64
63
)
65
64
@@ -179,7 +178,7 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment =
179
178
180
179
imports = collect_imports (ctx , semantics )
181
180
182
- runtime_details = _get_runtime_details (ctx , semantics , is_test )
181
+ runtime_details = _get_runtime_details (ctx , semantics )
183
182
if ctx .configuration .coverage_enabled :
184
183
extra_deps = semantics .get_coverage_deps (ctx , runtime_details )
185
184
else :
@@ -278,7 +277,7 @@ def _declare_executable_file(ctx):
278
277
279
278
return executable
280
279
281
- def _get_runtime_details (ctx , semantics , is_test ):
280
+ def _get_runtime_details (ctx , semantics ):
282
281
"""Gets various information about the Python runtime to use.
283
282
284
283
While most information comes from the toolchain, various legacy and
@@ -287,7 +286,6 @@ def _get_runtime_details(ctx, semantics, is_test):
287
286
Args:
288
287
ctx: Rule ctx
289
288
semantics: A `BinarySemantics` struct; see `create_binary_semantics_struct`
290
- is_test: bool; True if the rule is a test rule (has `test=True`), False if not
291
289
292
290
Returns:
293
291
A struct; see inline-field comments of the return value for details.
@@ -316,7 +314,6 @@ def _get_runtime_details(ctx, semantics, is_test):
316
314
if not effective_runtime :
317
315
fail ("Unable to find Python runtime" )
318
316
319
- extra_test_env = {}
320
317
if effective_runtime :
321
318
direct = [] # List of files
322
319
transitive = [] # List of depsets
@@ -329,12 +326,6 @@ def _get_runtime_details(ctx, semantics, is_test):
329
326
direct .append (effective_runtime .coverage_tool )
330
327
if effective_runtime .coverage_files :
331
328
transitive .append (effective_runtime .coverage_files )
332
- if is_test :
333
- py_test_toolchain = ctx .exec_groups ["test" ].toolchains [PY_TEST_TOOLCHAIN_TYPE ]
334
- if py_test_toolchain :
335
- coverage_rc = py_test_toolchain .py_test_info .coverage_rc
336
- extra_test_env = {"COVERAGE_RC" : coverage_rc .files .to_list ()[0 ].short_path }
337
- direct .extend (coverage_rc .files .to_list ())
338
329
runtime_files = depset (direct = direct , transitive = transitive )
339
330
else :
340
331
runtime_files = depset ()
@@ -366,9 +357,6 @@ def _get_runtime_details(ctx, semantics, is_test):
366
357
# be included. For in-build runtimes, this shold include the interpreter
367
358
# and any supporting files.
368
359
runfiles = ctx .runfiles (transitive_files = runtime_files ),
369
- # extra_test_env: dict[str, str]; Additional environment variables to
370
- # set when running the test.
371
- extra_test_env = extra_test_env ,
372
360
)
373
361
374
362
def _maybe_get_runtime_from_ctx (ctx ):
@@ -861,22 +849,8 @@ def _create_providers(
861
849
Returns:
862
850
A list of modern providers.
863
851
"""
864
-
865
852
providers = [
866
- DefaultInfo (
867
- executable = executable ,
868
- files = default_outputs ,
869
- default_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
870
- ctx ,
871
- runfiles_details .default_runfiles ,
872
- ),
873
- data_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
874
- ctx ,
875
- runfiles_details .data_runfiles ,
876
- ),
877
- ),
878
853
create_instrumented_files_info (ctx ),
879
- _create_run_environment_info (ctx , inherited_environment , runtime_details .extra_test_env ),
880
854
PyExecutableInfo (
881
855
main = main_py ,
882
856
runfiles_without_exe = runfiles_details .runfiles_without_exe ,
@@ -946,9 +920,22 @@ def _create_providers(
946
920
runtime_details = runtime_details ,
947
921
)
948
922
providers .extend (extra_providers )
949
- return providers
923
+ environemnt_info = _create_run_environment_info (ctx , inherited_environment )
924
+ binary_info = struct (
925
+ executable = executable ,
926
+ files = default_outputs ,
927
+ default_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
928
+ ctx ,
929
+ runfiles_details .default_runfiles ,
930
+ ),
931
+ data_runfiles = _py_builtins .make_runfiles_respect_legacy_external_runfiles (
932
+ ctx ,
933
+ runfiles_details .data_runfiles ,
934
+ ),
935
+ )
936
+ return providers , binary_info , environemnt_info
950
937
951
- def _create_run_environment_info (ctx , inherited_environment , extra_test_env ):
938
+ def _create_run_environment_info (ctx , inherited_environment ):
952
939
expanded_env = {}
953
940
for key , value in ctx .attr .env .items ():
954
941
expanded_env [key ] = _py_builtins .expand_location_and_make_variables (
@@ -957,8 +944,7 @@ def _create_run_environment_info(ctx, inherited_environment, extra_test_env):
957
944
expression = value ,
958
945
targets = ctx .attr .data ,
959
946
)
960
- expanded_env .update (extra_test_env )
961
- return RunEnvironmentInfo (
947
+ return struct (
962
948
environment = expanded_env ,
963
949
inherited_environment = inherited_environment ,
964
950
)
0 commit comments