1. Anthony Tuininga
  2. cx_Freeze

Commits

Anthony Tuininga  committed b3e037a

Search the directory in which the original image is found first as is done in
the Python source and if that fails, then search the system path in the normal
way. Thanks to Kelvin You for the description of the problem and the original
patch.

  • Participants
  • Parent commits c64a0d6
  • Branches default

Comments (0)

Files changed (2)

File setup.py

View file
 
 # build utility module
 if sys.platform == "win32":
-    libraries = ["imagehlp"]
+    libraries = ["imagehlp", "Shlwapi"]
 else:
     libraries = []
 utilModule = Extension("cx_Freeze.util", ["source/util.c"],

File source/util.c

View file
 #ifdef MS_WINDOWS
 #include <windows.h>
 #include <imagehlp.h>
+#include <Shlwapi.h>
 
 #pragma pack(2)
 
     ULONG virtualAddress,               // computed virtual address
     ULONG parameter)                    // parameter (value depends on reason)
 {
+    char imagePath[MAX_PATH + 1];
     char fileName[MAX_PATH + 1];
 
     switch (reason) {
         case BindImportModule:
-            if (!SearchPath(NULL, dllName, NULL, sizeof(fileName), fileName,
-                    NULL))
-                return FALSE;
+            strcpy(imagePath, imageName);
+            PathRemoveFileSpec(imagePath);
+            if (!SearchPath(imagePath, dllName, NULL, sizeof(fileName),
+                    fileName, NULL)) {
+                if (!SearchPath(NULL, dllName, NULL, sizeof(fileName),
+                        fileName, NULL))
+                    return FALSE;
+            }
             Py_INCREF(Py_None);
             if (PyDict_SetItemString(g_ImageNames, fileName, Py_None) < 0)
                 return FALSE;
         default:
             break;
     }
+
     return TRUE;
 }