tags:

views:

1637

answers:

2

Hello,

When using py2exe to distribute Python applications with wxPython, some MSVC DLLs are usually needed to make the .exe work on freshly installed machines. In particular, the two most common DLLs are msvcp71.dll and msvcr71.dll

The former can be included in the .exe using this tip. However, the latter is just placed in the dist dir by py2exe and not into the executable, even if I specifically ask to include it.

Any idea how to cause py2exe to include both inside the .exe ?

+5  A: 

Wouldn't it fail to launch, then? You want msvcr71.dll in the same directory as the exe, so that the library loader will be able to find and link it into the application's memory map.

It's needed for basic operation, so you can't just let py2exe unpack it with the rest of the DLLs.

John Millikin
I think you don't understand how DLLs and py2exe work. py2exe bundles DLLs into an executable, and then extracts and loads them at runtime before running the Python part. To perform the extraction, msvcr71.dll needs to already be present.
John Millikin
Do you mean that the .exe file created by py2exe needs msvcr71.dll to extract and load the DLLs from itself?
Eli Bendersky
+1  A: 

py2exe can't do this. You can wrap py2exe (there is an example on the wiki showing how to do that with NSIS); you could build your own wrapper if using NSIS or InnoSetup wasn't an option.

Alternatively, if you're positive that your users will have a compatible copy of msvcr71.dll installed (IIRC Vista or XP SP2 users), then you could get away without including it. More usefully, perhaps, if you use Python 2.3 (or older), then Python links against msvcr.dll rather than msvcr71.dll, and any Windows user will have that installed, so you can just not worry about it.

Tony Meyer
The problem is with wxPython, which does link against msvcr71.dll
Eli Bendersky
If you go backwards far enough in the wxPython releases, you'll find one that links against msvcr.dll instead of msvcr71.dll, just as with Python. It seems unlikely that all of this would be worth doing, but I don't know your circumstances, of course.
Tony Meyer