Hi Everyone,
I am having trouble getting a manifest to work with my wxPython
application. This is almost straight from the sample application so I
am really baffled. The sample version works fine for me with nice
looking buttons etc.
Setup.py is below. Can anyone spot the problem?
Thanks,
Davy Mitchell
Mood News
- BBC News Headlines Auto-Classified as Good, Bad or Neutral.
http://www.latedecember.com/sites/moodnews/
# setup.py
from distutils.core import setup
import py2exe, os, sys
manifest_template = '''
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="5.0.0.0"
processorArchitecture="x86"
name="%(prog)s"
type="win32"
/>
<description>%(prog)s Program</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
'''
RT_MANIFEST = 24
zipfile = r"lib\shardlib"
options = {"py2exe": {"compressed": 1,
"optimize": 2}}
···
################################################################
import os
class InnoScript:
def __init__(self,
name,
lib_dir,
dist_dir,
windows_exe_files = [],
lib_files = [],
version = "1.0"):
self.lib_dir = lib_dir
self.dist_dir = dist_dir
if not self.dist_dir[-1] in "\\/":
self.dist_dir += "\\"
self.name = name
self.version = version
self.windows_exe_files = [self.chop(p) for p in windows_exe_files]
self.lib_files = [self.chop(p) for p in lib_files]
def chop(self, pathname):
assert pathname.startswith(self.dist_dir)
return pathname[len(self.dist_dir):]
def create(self, pathname="dist\\LateDecember.iss"):
self.pathname = pathname
ofi = self.file = open(pathname, "w")
print >> ofi, "; WARNING: This script has been created by
py2exe. Changes to this script"
print >> ofi, "; will be overwritten the next time py2exe is run!"
print >> ofi, r"[Setup]"
print >> ofi, r"AppName=%s" % self.name
print >> ofi, r"AppVerName=%s %s" % (self.name, self.version)
print >> ofi, r"DefaultDirName={pf}\%s" % self.name
print >> ofi, r"DefaultGroupName=%s" % self.name
print >> ofi, r"OutputBaseFilename=%s" % self.name
print >> ofi
print >> ofi, r"[Files]"
for path in self.windows_exe_files + self.lib_files:
print >> ofi, r'Source: "%s"; DestDir: "{app}\%s"; Flags:
ignoreversion' % (path, os.path.dirname(path))
print >> ofi
print >> ofi, r"[Icons]"
for path in self.windows_exe_files:
print >> ofi, r'Name: "{group}\%s"; Filename: "{app}\%s"' % \
(self.name, path)
print >> ofi, 'Name: "{group}\Uninstall %s"; Filename:
"{uninstallexe}"' % self.name
def compile(self):
try:
import ctypes
except ImportError:
try:
import win32api
except ImportError:
import os
os.startfile(self.pathname)
else:
print "Ok, using win32api."
win32api.ShellExecute(0, "compile",
self.pathname,
None,
None,
0)
else:
print "Cool, you have ctypes installed."
res = ctypes.windll.shell32.ShellExecuteA(0, "compile",
self.pathname,
None,
None,
0)
if res < 32:
raise RuntimeError, "ShellExecute failed, error %d" % res
################################################################
from py2exe.build_exe import py2exe
class build_installer(py2exe):
# This class first builds the exe file(s), then creates a Windows installer.
# You need InnoSetup for it.
def run(self):
# First, let py2exe do it's work.
py2exe.run(self)
lib_dir = self.lib_dir
dist_dir = self.dist_dir
# create the Installer, using the files py2exe has created.
script = InnoScript("LateDecemberBackup",
lib_dir,
dist_dir,
self.windows_exe_files,
self.lib_files)
print "*** creating the inno setup script***"
script.create()
print "*** compiling the inno setup script***"
script.compile()
# Note: By default the final setup.exe will be in an Output
subdirectory.
################################################################
# find pythoncard resources, to add as 'data_files'
pycard_resources=[]
for filename in os.listdir('.'):
if filename.find('.rsrc.')>-1:
pycard_resources+=[filename]
#Documentation
doc_resources=[]
doc_resources+=["docs\index.html"]
doc_resources+=["docs\ldb1.png"]
doc_resources+=["docs\ldb2.png"]
doc_resources+=["docs\pc.css"]
#Runtime files
rt_resources=[]
rt_resources+=["folders.txt"]
# includes for py2exe
includes=[]
for comp in ['button','image','staticbox','list',
'statictext','textarea','textfield','passwordfield','gauge']:
includes += ['PythonCard.components.'+comp]
print 'includes',includes
opts = { 'py2exe': { 'includes':includes, 'excludes':['Image'] } }
print 'opts',opts
# end of py2exe stuff
setup(name='LateDecemberBackup',
author = 'Davy Mitchell',
windows=["LateDecemberBackup.py"],
other_resources = [(RT_MANIFEST, 1, manifest_template %
dict(prog="LateDecemberBackup"))],
options=opts,
cmdclass = {"py2exe": build_installer},
zipfile = zipfile,
data_files=[('.',rt_resources),('.',pycard_resources),('docs',doc_resources)]
)