On Mon, 20 Sep 2010 15:48:29 +0200, Florian Höch <[email protected]>
wrote:
> Am 20.09.2010 15:29, schrieb Giovanni Bajo:
>> On 9/20/2010 3:21 PM, Giovanni Bajo wrote:
>>> On 9/19/2010 7:22 PM, Florian Höch wrote:
>>>> Ok, I've made progress. I added a lot of print's and tracked the
error
>>>> to the uuid module from the standard library.
>>>>
>>>> Actually, using r854 does not solve the underlying problem. The
problem
>>>> is that uuid uses ctypes.find_library and ctypes.CDLL to find and
load
>>>> the C standard library to access some of its functions. With Python
2.6
>>>> and later, this is msvcr90.dll.
>>>>
>>>> If you build an executable with pyinstaller r854, the msvcr90.dll
will
>>>> be in a subfolder Microsoft.VC90.CRT and is simply not found by
>>>> ctypes.find_library. Normally this would throw an exception, but it
is
>>>> catched and then silently ignored inside uuid.
>>>>
>>>> If you build with pyinstaller r855 and later, msvcr90.dll will be
next
>>>> to the executable. There, it will be found by ctypes.find_library,
and
>>>> when it tries to load it using ctypes.CDLL, the R6034 error dialog
>>>> appears (before it throws the exception, which is silently ignored
like
>>>> I said). The application should run normal after that if it not
>>>> absolutely requires access to the C library via ctypes (uuid should
>>>> work
>>>> regardless as far as I can tell).
>>>>
>>>> All applications that actually require access to the C library via
>>>> ctypes will probably fail at some point, regardless of the
pyinstaller
>>>> version used to create them.
>>>
>>> Thanks for the analysys. A possible solution would be to patch
>>> find_library at runtime through a runtime hook (and its cousing
>>> find_msvcrt(), which is a shortcut to find_library("c") under Windows,
>>> as far as I can tell).
>>>
>>> But what should we do? My understand is that CDLL() simply calls
>>> LoadLibrary() on Windows. Why LoadLibrary("msvcr90.dll") fails when
the
>>> application is packaged by PyInstaller? If I understand correctly it
>>> fails whether if the DLL is in a subdirectory (silent fail) or the DLL
>>> is next to the executable (R6034). Is it really impossible for a
>>> PyInstaller-packaged binary to dynamically load msvcr90.dll? What
would
>>> be the correct Win32 API code to do it? Maybe there is some activation
>>> context needed?
>>
>> Something like this maybe?
>>
http://www.gamedev.net/community/forums/topic.asp?topic_id=535384&whichpage=1&#3459179
> 
> Hmm, this could also work. With CreateActCtx it should be possible to 
> keep the exe's manifest external (as XML file), so for onefile exe's, it

> could be part of the archive.

Great! I also saw that Python itself does a CreateActCtx just before
LoadLibrary (dynload_nt) for every .pyd.

BTW it might be worth adding a simple regression test in buildtests, that
tries to load msvcrt through ctypes.
-- 
Giovanni Bajo   ::  [email protected]
Develer S.r.l.  ::  http://www.develer.com

My Blog: http://giovanni.bajo.it

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

Reply via email to