Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Windows port: Monkeypatch subprocess.Popen

But only when executed in an MinGW/MSYS context. This makes sure
all subprocesses (via subprocess.Popen/call/check_call) are
automatically wrapped by "sh.exe -c", simulating an unbroken
chain of msys programs -> there's no msys-python port atm, so we're
forced to use the native windows Python port for g-ir-scanner during
build time. This is not ideal, but it works.
  • Loading branch information...
commit 525ca5723d9d78632f6f8618a53ed7de4105f310 1 parent 852f17c
@dieterv authored
Showing with 15 additions and 0 deletions.
  1. +9 −0 giscanner/
  2. +6 −0 giscanner/
9 giscanner/
@@ -373,6 +373,15 @@ def write_output(data, options):
_error("while writing output: %s" % (e.strerror, ))
def scanner_main(args):
+ if os.environ.get('MSYSTEM') == 'MINGW32':
+ # These workarounds will probably go away when MSYS grows itself a
+ # Python port that can be used during build-time. But let's not hope
+ # for that to happen any time soon...
+ # Monkeypatch subprocess.Popen so 'sh.exe' is automatically inserted
+ # on each Popen/call/check_call invocation
+ subprocess.Popen = utils.MsysPopen
parser = _get_option_parser()
(options, args) = parser.parse_args(args)
6 giscanner/
@@ -139,3 +139,9 @@ def files_are_identical(path1, path2):
return buf1 == buf2
+_Popen = subprocess.Popen
+class MsysPopen(_Popen):
+ def __init__(self, args, **kwargs):
+ newargs = ['sh.exe', '-c', ' '.join(args)]
+ return _Popen.__init__(self, newargs, **kwargs)
Please sign in to comment.
Something went wrong with that request. Please try again.