about summary refs log tree commit diff
path: root/kcc.py
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@iosphe.re>2015-10-28 16:51:02 +0100
committerPaweł Jastrzębski <pawelj@iosphe.re>2015-10-28 16:51:02 +0100
commit1152655061e8f7f9696cb1e7f8bb9a6888f9a776 (patch)
tree24f72d79f962a9a5297462d8d84ae9b09486e26d /kcc.py
parentLinux: GUI update (diff)
downloadkcc-1152655061e8f7f9696cb1e7f8bb9a6888f9a776.tar.gz
kcc-1152655061e8f7f9696cb1e7f8bb9a6888f9a776.tar.bz2
kcc-1152655061e8f7f9696cb1e7f8bb9a6888f9a776.zip
Miscellaneous tweaks
Diffstat (limited to 'kcc.py')
-rwxr-xr-xkcc.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/kcc.py b/kcc.py
index 220f5db..0029ad7 100755
--- a/kcc.py
+++ b/kcc.py
@@ -23,7 +23,7 @@ if sys.version_info[0] != 3:
     print('ERROR: This is Python 3 script!')
     exit(1)
 
-# OS specific PATH variable workarounds
+# OS specific workarounds
 import os
 if sys.platform.startswith('darwin'):
     if getattr(sys, 'frozen', False):
@@ -34,6 +34,23 @@ if sys.platform.startswith('darwin'):
     else:
         os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/osx/:' + os.environ['PATH']
 elif sys.platform.startswith('win'):
+    import multiprocessing.popen_spawn_win32 as forking
+
+    class _Popen(forking.Popen):
+        def __init__(self, *args, **kw):
+            if hasattr(sys, 'frozen'):
+                # noinspection PyProtectedMember
+                os.putenv('_MEIPASS2', sys._MEIPASS)
+            try:
+                super(_Popen, self).__init__(*args, **kw)
+            finally:
+                if hasattr(sys, 'frozen'):
+                    if hasattr(os, 'unsetenv'):
+                        os.unsetenv('_MEIPASS2')
+                    else:
+                        os.putenv('_MEIPASS2', '')
+    forking.Popen = _Popen
+
     if getattr(sys, 'frozen', False):
         os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
     else: