|
17 | 17 | import locale |
18 | 18 | import pathlib |
19 | 19 | import pkgutil |
| 20 | +import platform |
20 | 21 | import queue |
21 | 22 | import re |
22 | 23 | import subprocess |
@@ -642,6 +643,14 @@ def _subproc_default(self, *, session, stdin, stage, stage_num, stage_tot_num, c |
642 | 643 | # backslashes will require extra escaping. |
643 | 644 | args = shlex.split(cmd) |
644 | 645 | failed_proc_stderr = 'COMMAND FAILED (missing program or file):\n {0}'.format(cmd).encode('utf8') |
| 646 | + if platform.system() == 'Windows': |
| 647 | + # Modify args since subprocess.Popen() ignores PATH |
| 648 | + # * https://bugs.python.org/issue15451 |
| 649 | + # * https://bugs.python.org/issue8557 |
| 650 | + executable = shutil.which(args[0]) |
| 651 | + if executable is None: |
| 652 | + return FailedProcess(args, stdout=b'', stderr=failed_proc_stderr) |
| 653 | + args[0] = executable |
645 | 654 | if stdin is None: |
646 | 655 | stdin_bytes_or_none = None |
647 | 656 | else: |
@@ -669,6 +678,14 @@ def _subproc_live_output(self, *, session, stdin, stage, stage_num, stage_tot_nu |
669 | 678 | raise err.CodebraidError('"live_output" is currently not compatible with running a process that requires STDIN') |
670 | 679 | args = shlex.split(cmd) |
671 | 680 | failed_proc_stderr = 'COMMAND FAILED (missing program or file):\n {0}'.format(cmd).encode('utf8') |
| 681 | + if platform.system() == 'Windows': |
| 682 | + # Modify args since subprocess.Popen() ignores PATH |
| 683 | + # * https://bugs.python.org/issue15451 |
| 684 | + # * https://bugs.python.org/issue8557 |
| 685 | + executable = shutil.which(args[0]) |
| 686 | + if executable is None: |
| 687 | + return FailedProcess(args, stdout=b'', stderr=failed_proc_stderr) |
| 688 | + args[0] = executable |
672 | 689 | # Queue of bytes from stdout and stderr, plus string delims |
673 | 690 | print_queue = queue.Queue() |
674 | 691 | hash_bytes = session.hash[:64].encode('utf8') |
|
0 commit comments