[pywin32-checkins] pywin32/com pythoncom.py,1.3,1.4
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-10-31 23:47:51
|
Update of /cvsroot/pywin32/pywin32/com In directory sc8-pr-cvs1:/tmp/cvs-serv30595/com Modified Files: pythoncom.py Log Message: For frozen programs, if a sys.path entry is a file, look in its directory. pythoncom now simply re-uses pywintypes logic rather than duplicating it. Index: pythoncom.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/pythoncom.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pythoncom.py 6 Oct 2003 13:05:56 -0000 1.3 --- pythoncom.py 31 Oct 2003 23:47:46 -0000 1.4 *************** *** 1,32 **** # Magic utility that "redirects" to pythoncomxx.dll ! ! def __import(modname): ! import win32api, imp, sys, os ! suffix = "" ! if win32api.__file__.endswith("_d.pyd")>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 --- 1,3 ---- # Magic utility that "redirects" to pythoncomxx.dll ! import pywintypes ! pywintypes.__import_pywin32_system_module__("pythoncom", globals()) |