Which version of MSVC?90.DLL's to distribute with Python 2.6 basedPy2exe executables?

J

Jonathan Hartley

Jonathan,

<snipped>
I'm going to try to run vcredist_x86.exe automatically (as opposed to
asking my users to download and run it manually). I don't currently
have any installer, so I'm going to run vcredist_x86.exe on my
application start-up. Some logic like this seems to do this trick:

if platform.system() == 'Windows':
command = [path.join('lib', 'vcredist_x86.exe'), '/q']
retcode = subprocess.call(command)
if retcode != 0:
sys.stderr.write(
'Return value %d from vcredist_x86.exe\n' %
(retcode,))

This seems to work. My py2exe program will now run out of the box on a
bare-bones Windows XP install. (note: running 'vcredist_x86.exe /qu'
will uninstall the DLLs again)
</snipped>

I'm surprised that this technique works because the Python interpreter
itself needs to find the MSVC*90.DLL files before it can startup and run
your program that installs the MSVC*90.DLL files. Sort of a chicken and
egg scenario.

Malcolm

Yeah, I was still clearly a little fuzzy-headed from Christmas when I
even thought to try that. It only appeared to work, I was trying it on
another machine (not my bare-bones VM) and evidently the required
msvcr90.dll was already installed elsewhere on that machine.

I'm just going to give in and stick the manifest and dll directly in
with my application as described by others earlier, from the cheapest
copy of Visual Studio I can lay my hands on.

Thanks to everyone for their help on this, it's been plaguing me for ages.

Jonathan Hartley Made of meat. http://tartley.com
(e-mail address removed) +44 7737 062 225 twitter/skype: tartley
 
D

David Bolen

Jonathan Hartley said:
I guess I really need an installer. Oh well.

This need not be that much of a hurdle. Several solutions exist such
as Inno Setup (my personal preference), NSIS, etc... which are not
hard to create a solid installer with. I suspect your end users will
appreciate it too since your application (even if trivial) will
install/uninstall just like other standard applications. Combining
py2exe with such an installer is a solid combination for deployment
under Windows.

It could also help you over time since you'll have better control if
needed over how future versions handle updates, can control menus,
shortcuts, etc.. Even if a start menu shortcut just opens up a
console window with your text based application, it's probably easier
for users then telling them to open such a window manually, switch to
the right directory, and start your script.

You can arrange to have the redist installer run from within your
installation script, so it's a one-time hit rather than each time your
application starts.

-- David
 
K

kakarukeys

I tried on a fresh XP on VM. I moved all dlls in C:\WINDOWS\WinSxS
which are in the file handles shown by Process Explorer including the
3 CRT dlls to the my dist folder and the two subfolders suggested by
http://wiki.wxpython.org/py2exe. It didn't work out. My app couldn't
start. Windows XP gave a cryptic error asking me to reinstall the app.

After installing vcredist_x86.exe, my app starts fine. There isn't a
choice here. You HAVE TO bundle vcredist_x86.exe with your installer
and convince your customers that it is necessary to increase the file
size by 2MB.

If anyone figure out how to do as http://wiki.wxpython.org/py2exe, or
on a Python compiled with a free GNU compiler, avoiding all these BS.
I will pay him/her $10.
 
W

Waldemar Osuch

I tried on a fresh XP on VM. I moved all dlls in C:\WINDOWS\WinSxS
which are in the file handles shown by Process Explorer including the
3 CRT dlls to the my dist folder and the two subfolders suggested byhttp://wiki.wxpython.org/py2exe. It didn't work out. My app couldn't
start. Windows XP gave a cryptic error asking me to reinstall the app.

After installing vcredist_x86.exe, my app starts fine. There isn't a
choice here. You HAVE TO bundle vcredist_x86.exe with your installer
and convince your customers that it is necessary to increase the file
size by 2MB.

If anyone figure out how to do ashttp://wiki.wxpython.org/py2exe, or
on a Python compiled with a free GNU compiler, avoiding all these BS.
I will pay him/her $10.

I have a method that does not involve installing the runtime and still
works on a "virgin" machine.

The target machines are locked desktops and installing anything
on them equals to a 2 month long approval process.
"The Preventer of IT" strikes again :)

But anyway, the method involves editing python26.dll in order to
remove
dependency references and then dropping msvcr90.dll in the same
directory as the py2exe produced executable. Here is dir /b:

lib/
msvcr90.dll
python26.dll <-- tweaked
UI.exe

The method works with a program using wxPython.

I have used Resource Hacker http://www.angusj.com/resourcehacker/
for actual editing.
You have to find <dependency> section of the manifest and remove
everything between <dependentAssembly> tags

Before:
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT"
version="9.0.21022.8" processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>

After:
<dependency>
<dependentAssembly>
</dependentAssembly>
</dependency>

Is the method elegant? Nope.
Does it work? It does for me.
Use it at your own risk etc. The regular disclaimers apply.

The approach was gleaned from a thread at PIL mailing list.
http://mail.python.org/pipermail/image-sig/2009-October/005916.html

waldemar
 
P

python

Waldemar,

Thank your for sharing your technique - works great with 32-bit Python
2.6.4.

Has anyone tried this with a 64-bit version of Python?

Malcolm
 
J

Jonathan Hartley

the method involves editing python26.dll in order to remove
dependency references and then dropping msvcr90.dll in the same
directory as the py2exe produced executable.

Clever idea Waldemar, thanks for that, but for the moment, using the
dll as a win32 assembly (ie. with a manifest file, as described by
others earlier in this thread) seems to work just as well.


So, for the record, I have included these two files in a directory
called 'Microsoft.VC90.CRT', which is in the same dir as my
executable, and that makes everything work, even on my 'bare bones'
windows XP virtual machine.

The end result is a small game some friends and I put together for the
PyWeek competition a few months ago. If anyone wants to see exactly
how the resulting dll and manifest look, you can download the Windows
binary under the 'featured downloads' from here:
http://code.google.com/p/brokenspell/

I appreciate David Bolen's comment that an installer isn't that hard
to put together: Acknowledged, but for the moment I still seem to be
getting away without needing one.

Best regards,

Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top