Skip to content

Commit 677b45e

Browse files
Alexpuxlazka
authored andcommitted
msys monkeypatch os system via sh exe
Co-authored-by: Алексей <[email protected]>
1 parent 7223f88 commit 677b45e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ def get_platform():
7777
return sys.platform
7878

7979

80+
# On MSYS, os.system needs to be wrapped with sh.exe
81+
# as otherwise all the io redirection will fail.
82+
# Arguably, this could happen inside the real os.system
83+
# rather than this monkey patch.
84+
if sys.platform == "win32" and "MSYSTEM" in os.environ:
85+
os_system = os.system
86+
def msys_system(command):
87+
command_in_sh = 'sh.exe -c "%s"' % command.replace("\\", "\\\\")
88+
return os_system(command_in_sh)
89+
os.system = msys_system
90+
8091
CROSS_COMPILING = ("_PYTHON_HOST_PLATFORM" in os.environ)
8192
HOST_PLATFORM = get_platform()
8293
MS_WINDOWS = (HOST_PLATFORM == 'win32')

0 commit comments

Comments
 (0)