[Python-au] py2exe mscvr90.dll problem
Mike Dewhirst
miked at dewhirst.com.au
Thu Jul 16 01:16:35 UTC 2009
Andrew
I found Werner's wiki to be very useful. This is the setup.py I ended up
with and am finding it works well.
Cheers
Mike
# ======================================================#
# File automagically generated by GUI2Exe version 0.3
# Andrea Gavana, 01 April 2007
# ======================================================#
# http://wiki.wxpython.org/Deployment
# Modified initially for the above wiki and and copiously
# annotated by werner.bruhin at free.fr
#
# Finally tweaked by Mike Dewhirst to build an automated
# installation process, 15 July 2009
# ======================================================#
from distutils.core import setup
import py2exe
import glob
import os
import zlib
import shutil
# Remove the build folder
shutil.rmtree("build", ignore_errors=True)
# do the same for dist folder
shutil.rmtree("dist", ignore_errors=True)
class Target(object):
""" A simple class that holds information on our executable file. """
def __init__(self, **kw):
""" Default class constructor. Update as you need. """
self.__dict__.update(kw)
# Ok, let's explain why I am doing that.
# Often, data_files, excludes and dll_excludes (but also resources)
# can be very long list of things, and this will clutter too much
# the setup call at the end of this file. So, I put all the big lists
# here and I wrap them using the textwrap module.
baseFolder, progFolder = os.path.split(os.getcwd())
inst_target = 'install_app.py'
data_files = ['add\\data291.exe',
'add\\PrivConv.exe',
'add\\install_dialog.txt',
'add\\about.txt',]
includes = []
excludes = []
packages = []
dll_excludes = []
icon_resources = []
bitmap_resources = []
other_resources = []
# This is a place where the user custom code may go. You can do almost
# whatever you want, even modify the data_files, includes and friends
# here as long as they have the same variable name that the setup call
# below is expecting.
#
# The following will copy the MSVC run time dll's
# (msvcm90.dll, msvcp90.dll and msvcr90.dll) and
# the Microsoft.VC90.CRT.manifest which I keep in the
# "Py26MSdlls" folder into the dist folder
#
# depending on wx widgets you use, you might need to add
# gdiplus.dll to the above collection
py26MSdll = glob.glob(baseFolder + '\\Py26MSdlls\\*.*')
# following works from Windows XP +
# if you need to deploy to older MS Win versions then I found that on Win2K
# it will also work if the files are put into the application folder without
# using a sub-folder.
data_files += [("Microsoft.VC90.CRT", py26MSdll),
("lib\\Microsoft.VC90.CRT", py26MSdll),
]
# Ok, now we are going to build our target class.
# I chose this building strategy as it works perfectly for me :-D
'''
# Werner's gui sample
GUI2Exe_Target_1 = Target(
# what to build
script = "simplewx.py",
icon_resources = icon_resources,
bitmap_resources = bitmap_resources,
other_resources = other_resources,
dest_base = "simplewx",
version = "0.1",
company_name = "No Company",
copyright = "No Copyrights",
name = "Py2Exe Sample File"
)
'''
# md's console stuff
_target = Target(
# what to build
script = inst_target,
icon_resources = icon_resources,
bitmap_resources = bitmap_resources,
other_resources = other_resources,
dest_base = "install_app",
version = "0.0",
company_name = "",
copyright = "CC Share Alike",
name = "Data 2009.1 Housekeeper"
)
# That's serious now: we have all (or almost all) the options py2exe
# supports. I put them all even if some of them are usually defaulted
# and not used. Some of them I didn't even know about.
'''
Werner's original values
"compressed": 2,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 3,
"dist_dir": "dist",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
'''
setup(
data_files = data_files,
options = {"py2exe": {"compressed": 0,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 2,
"dist_dir": "dist",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
zipfile = "lib\\library.zip",
console = [_target],
#windows = [GUI2Exe_Target_1]
)
# This is a place where any post-compile code may go.
# You can add as much code as you want, which can be used, for example,
# to clean up your folders or to do some particular post-compilation
# actions.
# And we are done. That's a setup script :-D
More information about the python-au
mailing list