--- sip-5.3.0/sipbuild/builder.py.orig	2020-07-07 09:23:59.242531000 +0200
+++ sip-5.3.0/sipbuild/builder.py	2020-07-07 09:25:02.079143700 +0200
@@ -380,7 +380,7 @@
             # Remove any callable name.
             module = module.split(':')[0]
 
-            if project.py_platform == 'win32':
+            if project.py_platform == 'win32' and "MSYSTEM" not in os.environ:
                 script += '.bat'
 
             project.progress("Generating the {} script".format(script))
@@ -390,14 +390,18 @@
 
             script_f = project.open_for_writing(script_path)
 
-            if project.py_platform == 'win32':
+            exe = sys.executable
+            if "MSYSTEM" in os.environ:
+                exe = os.popen(' '.join(['cygpath', '--unix', exe])).readline().strip()
+
+            if project.py_platform == 'win32' and "MSYSTEM" not in os.environ:
                 script_f.write(
                         '@{} -m {} %1 %2 %3 %4 %5 %6 %7 %8 %9\n'.format(
                                 sys.executable, module))
             else:
                 script_f.write('#!/bin/sh\n')
                 script_f.write(
-                        'exec %s -m %s ${1+"$@"}\n' % (sys.executable,
+                        'exec %s -m %s ${1+"$@"}\n' % (exe,
                                 module))
 
             script_f.close()
