Update of /cvsroot/pywin32/pywin32/win32/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv18255
Modified Files:
pywintypes.py
Log Message:
Look for pywintypes.dll in the sys.prefix directory - that is where it
goes for non-admin users, and LoadLibrary will fail to locate it (as
that is not on our path)
Index: pywintypes.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywintypes.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pywintypes.py 6 Oct 2003 13:05:10 -0000 1.3
--- pywintypes.py 26 Oct 2003 03:52:56 -0000 1.4
***************
*** 2,9 ****
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"):
--- 2,18 ----
def __import(modname):
! # *sigh* - non-admin installs will not have pywintypesxx.dll in the
! # system directory, so 'import win32api' will fail looking
! # for pywintypes - the exact DLL we are trying to load!
! # So if it exists in sys.prefix, then we try and load it from
! # there, as that way we can avoid the win32api import
! import imp, sys, os
! # See if this is a debug build.
! for suffix_item in imp.get_suffixes():
! if suffix_item[0]=='_d.pyd':
! suffix = '_d'
! break
! else:
! suffix = ""
filename = "%s%d%d%s.dll" % (modname, sys.version_info[0], sys.version_info[1], suffix)
if hasattr(sys, "frozen"):
***************
*** 18,31 ****
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")
--- 27,43 ----
h = None
else:
! if os.path.isfile(os.path.join(sys.prefix, filename)):
! found = os.path.join(sys.prefix, filename)
! else:
! # We could still avoid win32api here, but...
! import win32api
! # 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__)
__import("pywintypes")
|