Browse Source

HPCC-17532 Build Windows Client with Pyembed

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 years ago
parent
commit
4fa24613bc
2 changed files with 18 additions and 8 deletions
  1. 9 4
      plugins/py3embed/py3embed.cpp
  2. 9 4
      plugins/pyembed/pyembed.cpp

+ 9 - 4
plugins/py3embed/py3embed.cpp

@@ -447,11 +447,16 @@ MODULE_INIT(INIT_PRIORITY_STANDARD)
     // Make sure we are never unloaded (as Python may crash if we are)
     // we do this by doing a dynamic load of the pyembed library
 #ifdef _WIN32
-    ::GetModuleFileName((HINSTANCE)&__ImageBase, helperLibraryName, _MAX_PATH);
-    if (strstr(path, "py3embed"))
+    HINSTANCE me = GetModuleHandle("py3embed");
+    if (me)
     {
-        HINSTANCE h = LoadSharedObject(helperLibraryName, false, false);
-        DBGLOG("LoadSharedObject returned %p", h);
+        char helperLibraryName[_MAX_PATH];
+        ::GetModuleFileName(me, helperLibraryName, _MAX_PATH);
+        if (strstr(helperLibraryName, "py3embed"))
+        {
+            HINSTANCE h = LoadSharedObject(helperLibraryName, false, false);
+            DBGLOG("LoadSharedObject returned %p", h);
+        }
     }
 #else
     FILE *diskfp = fopen("/proc/self/maps", "r");

+ 9 - 4
plugins/pyembed/pyembed.cpp

@@ -453,11 +453,16 @@ MODULE_INIT(INIT_PRIORITY_STANDARD)
     // we do this by doing a dynamic load of the pyembed library
     // This also allows eclcc to be able to use the library for constant folding
 #ifdef _WIN32
-    ::GetModuleFileName((HINSTANCE)&__ImageBase, helperLibraryName, _MAX_PATH);
-    if (strstr(path, "py2embed"))
+    HINSTANCE me = GetModuleHandle("py2embed");
+    if (me)
     {
-        HINSTANCE h = LoadSharedObject(helperLibraryName, false, false);
-        DBGLOG("LoadSharedObject returned %p", h);
+        char helperLibraryName[_MAX_PATH];
+        ::GetModuleFileName(me, helperLibraryName, _MAX_PATH);
+        if (strstr(helperLibraryName, "py2embed"))
+        {
+            HINSTANCE h = LoadSharedObject(helperLibraryName, false, false);
+            DBGLOG("LoadSharedObject returned %p", h);
+        }
     }
 #else
     StringBuffer modname;