Skip to content

Commit

Permalink
Set default ComSpec when running on Windows (#1595)
Browse files Browse the repository at this point in the history
* set default ComSpec when running on Windows

Signed-off-by: Kevin Su <pingsutw@apache.org>

* lint

Signed-off-by: Kevin Su <pingsutw@apache.org>

* nit

Signed-off-by: Kevin Su <pingsutw@apache.org>

---------

Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Fabio Graetz <fabiograetz@googlemail.com>
  • Loading branch information
pingsutw authored and fg91 committed Apr 23, 2023
1 parent 50c2e38 commit 12660ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flytekit/extras/tasks/shell.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import os
import platform
import string
import subprocess
import typing
Expand Down Expand Up @@ -213,6 +214,9 @@ def execute(self, **kwargs) -> typing.Any:
print("\n==============================================\n")

try:
if platform.system() == "Windows" and os.environ.get("ComSpec") is None:
# https://github.com/python/cpython/issues/101283
os.environ["ComSpec"] = "C:\\Windows\\System32\\cmd.exe"
subprocess.check_call(gen_script, shell=True)
except subprocess.CalledProcessError as e:
files = os.listdir(".")
Expand Down Expand Up @@ -356,7 +360,6 @@ def execute(self, **kwargs) -> typing.Any:
# This utility function allows for the specification of env variables, arguments, and the actual script within the
# workflow definition rather than at `RawShellTask` instantiation
def get_raw_shell_task(name: str) -> RawShellTask:

return RawShellTask(
name=name,
debug=True,
Expand Down

0 comments on commit 12660ad

Please sign in to comment.