1. TortoiseHg
  2. TortoiseHg
  3. thg-winbuild

Commits

Steve Borho  committed 7300a7d

delay path pruning until the py2exe -b3 step

  • Participants
  • Parent commits 99140f7
  • Branches default

Comments (0)

Files changed (1)

File setup.py

View file
 sdkenv_vars = ('include', 'lib', 'mssdk', 'path', 'regkeypath', 'sdksetupdir',
                'sdktools', 'targetos', 'vcinstalldir', 'vcroot', 'vsregkeypath')
 
+def get_pruned_env(arch):
+    # Remove folders from %PATH% that contain QtCore4.dll, unless it is the
+    # PyQt4\bin folder for the executing Python environment
+    prefix = sys.exec_prefix.lower() + os.sep
+    deletions = []
+    fenv = get_sdkenv(arch).copy()
+    path = fenv.get('PATH', '').split(os.pathsep)
+    for dir in path:
+        if dir.lower().startswith(prefix):
+            continue
+        if os.path.exists(os.path.join(dir, 'QtCore4.dll')):
+            deletions.append(dir)
+    for dir in deletions:
+        print 'removing', dir, 'from PATH'
+        path.remove(dir)
+    fenv['PATH'] = os.pathsep.join(path)
+    return fenv
+
 def get_sdkenv(arch):
     if arch in sdkenvs:
         return sdkenvs[arch]
 def build_thg_installer(name, productid, arch):
     if not onlymsi:
         run(r'if exist dist rmdir /s /q dist', 'build-thg')
-        run_python(r'setup.py py2exe -b3', 'build-thg', env=get_sdkenv(arch))
+        run_python(r'setup.py py2exe -b3', 'build-thg', env=get_pruned_env(arch))
+
         for f in ('qscintilla2.dll', 'QtSvg4.dll', 'QtXml4.dll'):
             p = os.path.join(sys.exec_prefix, 'lib', 'site-packages',
                              'PyQt4', 'bin', f)
         sys.exit(1)
 
     path = installenv.get('PATH', '').split(os.pathsep)
-    prefix = sys.exec_prefix.lower() + os.sep
-    deletions = []
-    for dir in path:
-        if dir.lower().startswith(prefix):
-            continue
-        if os.path.exists(os.path.join(dir, 'QtCore4.dll')):
-            deletions.append(dir)
-        elif dir.endswith(r'Lib\site-packages\PyQt4\bin'):
-            deletions.append(dir)
-    for dir in deletions:
-        print 'removing', dir, 'from PATH'
-        path.remove(dir)
     scrpath = sys.exec_prefix + os.sep + 'Scripts'
     path.append(scrpath)