Skip to content

Commit

Permalink
msys monkeypatch os system via sh exe
Browse files Browse the repository at this point in the history
Co-authored-by: Алексей <[email protected]>
  • Loading branch information
Alexpux authored and lazka committed Aug 25, 2023
1 parent 555d752 commit 29d805b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ def get_platform():
return sys.platform


# On MSYS, os.system needs to be wrapped with sh.exe
# as otherwise all the io redirection will fail.
# Arguably, this could happen inside the real os.system
# rather than this monkey patch.
if sys.platform == "win32" and "MSYSTEM" in os.environ:
os_system = os.system
def msys_system(command):
command_in_sh = 'sh.exe -c "%s"' % command.replace("\\", "\\\\")
return os_system(command_in_sh)
os.system = msys_system

CROSS_COMPILING = ("_PYTHON_HOST_PLATFORM" in os.environ)
HOST_PLATFORM = get_platform()
MS_WINDOWS = (HOST_PLATFORM == 'win32')
Expand Down

0 comments on commit 29d805b

Please sign in to comment.