Update of /cvsroot/pywin32/pywin32/win32/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv7399/win32/lib
Modified Files:
pywintypes.py
Log Message:
Try and locate the extension on os.environ["PATH"], rather than relying
on LoadLibrary, as LoadLib uses the System32 directory before PATH.
Mainly for distutils, which can ensure the SYSTEM32 pywintypes is *not*
loaded.
Index: pywintypes.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywintypes.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pywintypes.py 31 Oct 2003 23:47:46 -0000 1.6
--- pywintypes.py 25 Nov 2003 10:26:23 -0000 1.7
***************
*** 15,19 ****
else:
suffix = ""
! 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)
--- 15,20 ----
else:
suffix = ""
! 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)
***************
*** 28,47 ****
break
else:
! raise ImportError, "Module '%s' isn't in frozen sys.path directories" % modname
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.
globs.update(mod.__dict__)
__import_pywin32_system_module__("pywintypes", globals())
-
--- 29,55 ----
break
else:
! raise ImportError, \
! "Module '%s' isn't in frozen sys.path directories" % modname
else:
! search_dirs = [sys.prefix] + \
! os.environ.get("PATH", "").split(os.pathsep)
! for d in search_dirs:
! found = os.path.join(d, filename)
! if os.path.isfile(found):
! break
else:
! # Eeek - can't find on the path. Try "LoadLibrary", as it
! # has slightly different semantics than a simple sys.path search
import win32api
# Normal Python needs these files in a directory somewhere on
! # %PATH%, so let Windows search it out for us. As win32api
! # loads pywintypes, we can simple get the module after the import
! h = win32api.GetModuleHandle(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.
globs.update(mod.__dict__)
__import_pywin32_system_module__("pywintypes", globals())
|