From aced21aebe681220827b265e42dd9efb0ad5e548 Mon Sep 17 00:00:00 2001 From: Vadim Mironov Date: Thu, 29 Jan 2026 23:32:34 +0000 Subject: [PATCH 1/3] fix: use powershell.exe instead of pwsh.exe for build_data_writer (#3552) Stock Windows ships with Windows PowerShell 5.1 (powershell.exe) but not PowerShell 7+ (pwsh.exe). Using pwsh.exe causes builds to fail on machines without PowerShell 7 installed. Also adds -ExecutionPolicy Bypass since Windows PowerShell defaults to Restricted policy which blocks .ps1 script execution. Fixes https://github.com/bazel-contrib/rules_python/issues/3552 Co-Authored-By: Claude Opus 4.5 --- python/private/py_executable.bzl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index c3ee1b92a8..59265fff75 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -1369,7 +1369,9 @@ def _write_build_data(ctx): action_args = ctx.actions.args() writer_file = ctx.files._build_data_writer[0] if writer_file.path.endswith(".ps1"): - action_exe = "pwsh.exe" + action_exe = "powershell.exe" + action_args.add("-ExecutionPolicy") + action_args.add("Bypass") action_args.add("-File") action_args.add(writer_file) inputs.add(writer_file) From 827ed988cbb2f9d9fc67031e209c87075b5e307a Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 30 Jan 2026 09:38:08 +0900 Subject: [PATCH 2/3] refactor: use add_all for arg construction. Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- python/private/py_executable.bzl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index 59265fff75..097c27d836 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -1370,10 +1370,12 @@ def _write_build_data(ctx): writer_file = ctx.files._build_data_writer[0] if writer_file.path.endswith(".ps1"): action_exe = "powershell.exe" - action_args.add("-ExecutionPolicy") - action_args.add("Bypass") - action_args.add("-File") - action_args.add(writer_file) + action_args.add_all([ + "-ExecutionPolicy", + "Bypass", + "-File", + writer_file, + ]) inputs.add(writer_file) else: action_exe = ctx.attr._build_data_writer[DefaultInfo].files_to_run From ea82c792a7954b76409e1463edabedcc3113dfba Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Thu, 29 Jan 2026 20:22:08 -0800 Subject: [PATCH 3/3] Doc why powershell.exe, bypass used --- python/private/py_executable.bzl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index 097c27d836..92fca2caf2 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -1369,8 +1369,12 @@ def _write_build_data(ctx): action_args = ctx.actions.args() writer_file = ctx.files._build_data_writer[0] if writer_file.path.endswith(".ps1"): + # powershell.exe is used for broader compatibility + # It is installed by default on most Windows versions action_exe = "powershell.exe" action_args.add_all([ + # Bypass execution policy is needed because, + # by default, Windows blocks ps1 scripts. "-ExecutionPolicy", "Bypass", "-File",