[pywin32-checkins] pywin32/com pythoncom.py,1.1,1.2
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-09-18 05:32:45
|
Update of /cvsroot/pywin32/pywin32/com In directory sc8-pr-cvs1:/tmp/cvs-serv2589 Modified Files: pythoncom.py Log Message: Ensure we load a local pythoncomxx.dll if we are frozen. Index: pythoncom.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/pythoncom.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pythoncom.py 27 Sep 2002 06:23:29 -0000 1.1 --- pythoncom.py 18 Sep 2003 05:32:35 -0000 1.2 *************** *** 2,19 **** def __import(modname): ! import win32api, imp, sys suffix = "" if win32api.__file__.find("_d")>0: suffix = "_d" filename = "%s%d%d%s.dll" % (modname, sys.version_info[0], sys.version_info[1], suffix) ! # win32 can find the DLL name. ! h = win32api.LoadLibrary(filename) ! found = win32api.GetModuleFileName(h) # Python can load the module mod = imp.load_module(modname, None, found, ('.dll', 'rb', imp.C_EXTENSION)) # and fill our namespace with it. globals().update(mod.__dict__) ! win32api.FreeLibrary(h) __import("pythoncom") ! del __import \ No newline at end of file --- 2,32 ---- def __import(modname): ! import win32api, imp, sys, os suffix = "" if win32api.__file__.find("_d")>0: suffix = "_d" filename = "%s%d%d%s.dll" % (modname, sys.version_info[0], sys.version_info[1], suffix) ! if hasattr(sys, "frozen"): ! # If we are running from a frozen program (py2exe, McMillan, freeze) ! # then we try and load the DLL from our sys.path ! for look in sys.path: ! found = os.path.join(look, filename) ! if os.path.isfile(found): ! break ! else: ! raise ImportError, "Module '%s' isn't in frozen sys.path directories" % modname ! h = None ! else: ! # Normal Python needs these files in a directory somewhere on ! # %PATH%, so let Windows search it out for us ! h = win32api.LoadLibrary(filename) ! found = win32api.GetModuleFileName(h) # Python can load the module mod = imp.load_module(modname, None, found, ('.dll', 'rb', imp.C_EXTENSION)) # and fill our namespace with it. globals().update(mod.__dict__) ! if h is not None: ! win32api.FreeLibrary(h) __import("pythoncom") ! del __import |