Browse Source

support _d

David Rose 17 years ago
parent
commit
1595033587
1 changed files with 14 additions and 4 deletions
  1. 14 4
      direct/src/extensions_native/extension_native_helpers.py

+ 14 - 4
direct/src/extensions_native/extension_native_helpers.py

@@ -3,14 +3,24 @@ __all__ = ["Dtool_ObjectToDict", "Dtool_funcToMethod", "Dtool_PreloadDLL"]
 
 
 import imp,sys,os
 import imp,sys,os
 
 
+is_python_d = False
+dll_suffix = ''
+
 if (sys.platform == "win32"):
 if (sys.platform == "win32"):
+    # If we launched from python_d.exe, we need to load libpanda_d.dll, etc.
+    is_python_d = (sys.executable.endswith('_d.exe'))
+    if is_python_d:
+        dll_suffix = '_d'
+    
     target = None
     target = None
+    filename = "libpandaexpress%s.dll" % (dll_suffix)
     for dir in sys.path + [sys.prefix]:
     for dir in sys.path + [sys.prefix]:
-        lib = os.path.join(dir, "libpandaexpress.dll")
+        lib = os.path.join(dir, filename)
         if (os.path.exists(lib)):
         if (os.path.exists(lib)):
             target = dir
             target = dir
     if (target == None):
     if (target == None):
-        raise "Cannot find libpandaexpress.dll"
+        message = "Cannot find %s" % (filename)
+        raise message
     path=os.environ["PATH"]
     path=os.environ["PATH"]
     if (path.startswith(target+";")==0):
     if (path.startswith(target+";")==0):
         os.environ["PATH"] = target+";"+path
         os.environ["PATH"] = target+";"+path
@@ -26,13 +36,13 @@ def Dtool_PreloadDLL(module):
         return
         return
     target = None
     target = None
     for dir in sys.path + [sys.prefix]:
     for dir in sys.path + [sys.prefix]:
-        lib = os.path.join(dir, module + ".dll")
+        lib = os.path.join(dir, module + dll_suffix + ".dll")
         if (os.path.exists(lib)):
         if (os.path.exists(lib)):
             target = dir
             target = dir
             break
             break
     if (target == None):
     if (target == None):
         raise "DLL loader cannot find "+module+"."
         raise "DLL loader cannot find "+module+"."
-    imp.load_dynamic(module, os.path.join(target, module + ".dll"))
+    imp.load_dynamic(module, os.path.join(target, module + dll_suffix + ".dll"))
 
 
 Dtool_PreloadDLL("libpandaexpress")
 Dtool_PreloadDLL("libpandaexpress")
 from libpandaexpress import *
 from libpandaexpress import *