[python-win32] Re: how to load 2 python COM DLLs in single app?

Niki Spahiev niki at vintech.bg
Mon Nov 29 09:40:11 CET 2004


Thomas Heller wrote:

> Are two characters enough? Four would be better, imo.

Only two because i replace python23.dll with pythonMN.dll

> Second, I had to make this change so that the unique option accepts a
> parameter:
> 
>>+        ("unique", 'u',
>>+         "patch all DLLs to be unique"),
> 
> must be changed to
> 
>>+        ("unique=", 'u',
> 
>                    ^
> 
>>+         "patch all DLLs to be unique"),

OK

> Third, it doesn't work for other cases ;-).  It tries to patch all dlls,
> except those that start with 'tcl' or 'tk'.  For the 'simple' sample in
> the distribution, it fails patching the wxwindows dll, plus the
> w9xpopen.exe helper.

I will fix that. It's meant for COM servers only not as universal 
solution. Probably wxwindows dll won't work if loaded twice and patching 
all references to it seems impossible.

> 
> IMO it would be better to first check whether a dll or an exe
> dynamically links to python23.dll, and only if it does the renaming and
> patching would take place.  For finding out the dlls an image links to,
> the py2exe_util extension's 'depends' function could be used.

OK

> Then, if I understand correctly, you simple replace all occurrences of
> 'python23.dll' in the image by the changed name. Wouldn't this be
> required to be case sesitive?  And wouldn't it be required to only make
> this change in the import table (maybe you take care of this by only
> replaing the first string you find).

I replace only single reference. If there are more exception is raised.

> Other comments:
> 
> 
>>+BOOT_UNIQUE = """
>>+def __load(name,ext):
>>+    import imp, sys
>>+    dirname = sys.prefix
>>+    path = dirname + '/' + name + ext
>>+    mod = imp.load_dynamic(name, path)
>>+##    mod.frozen = 1
>>+__load('zlib','%(UN)s.pyd')
>>+__load('pywintypes','%(UN)s.dll')
>>+__load('pythoncom','%(UN)s.dll')
>>+del __load
>>+"""
> 
> Why zlib?  It may or may not be included...

Because without zlib import from zip file is impossible :)

Niki


More information about the Python-win32 mailing list