Skip to content

Commit cc2fa38

Browse files
committed
Update py_executable.bzl
1 parent ae2dd35 commit cc2fa38

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

python/private/py_executable.bzl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ def _create_stage1_bootstrap(
783783

784784
def _find_launcher_maker(ctx):
785785
if rp_config.bazel_9_or_later:
786-
return ctx.toolchains[_LAUNCHER_MAKER_TOOLCHAIN_TYPE].binary
787-
return ctx.executable._windows_launcher_maker
786+
return (ctx.toolchains[_LAUNCHER_MAKER_TOOLCHAIN_TYPE].binary, _LAUNCHER_MAKER_TOOLCHAIN_TYPE)
787+
return (ctx.executable._windows_launcher_maker, None)
788788

789789
def _create_windows_exe_launcher(
790790
ctx,
@@ -805,15 +805,17 @@ def _create_windows_exe_launcher(
805805
launch_info.add("1" if use_zip_file else "0", format = "use_zip_file=%s")
806806

807807
launcher = ctx.attr._launcher[DefaultInfo].files_to_run.executable
808+
executable, toolchain = _find_launcher_maker(ctx)
808809
ctx.actions.run(
809-
executable = _find_launcher_maker(ctx),
810+
executable = executable,
810811
arguments = [launcher.path, launch_info, output.path],
811812
inputs = [launcher],
812813
outputs = [output],
813814
mnemonic = "PyBuildLauncher",
814815
progress_message = "Creating launcher for %{label}",
815816
# Needed to inherit PATH when using non-MSVC compilers like MinGW
816817
use_default_shell_env = True,
818+
toolchain = toolchain,
817819
)
818820

819821
def _create_zip_file(ctx, *, output, zip_main, runfiles):

tests/base_rules/py_executable_base_tests.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,18 @@ def _test_cross_compile_to_unix(name, config):
125125
name = name,
126126
impl = _test_cross_compile_to_unix_impl,
127127
target = name + "_subject",
128+
# Cross-compilation of py_test fails since the default test toolchain
129+
# requires an execution platform that matches the target platform.
128130
config_settings = {
129131
"//command_line_option:platforms": [platform_targets.EXOTIC_UNIX],
130-
},
132+
} if rp_config.bazel_9_or_later and not "py_test" in str(config.rule) else {},
131133
expect_failure = True,
132134
)
133135

134136
def _test_cross_compile_to_unix_impl(_env, _target):
135137
pass
136138

137-
_tests.append(_test_cross_compile_to_unix) if rp_config.bazel_9_or_later else None
139+
_tests.append(_test_cross_compile_to_unix)
138140

139141
def _test_executable_in_runfiles(name, config):
140142
rt_util.helper_target(

0 commit comments

Comments
 (0)