Update of /cvsroot/pywin32/pywin32/win32/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv2711
Modified Files:
pywintypes.py
Log Message:
Ensure we load a local pywintypesxx.dll if we are frozen.
Index: pywintypes.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywintypes.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pywintypes.py 5 Oct 2002 02:37:53 -0000 1.1
--- pywintypes.py 18 Sep 2003 05:33:13 -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("pywintypes")
! 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("pywintypes")
! del __import
|