I have a PySide app that I'm converting to an exe to be run on Windows 7 without any dependencies using py2exe.
Here's setup from setup.py
setup(windows=[{
"script" : "src/main.py",
"dest_base" : "xxx-setup-" + configuration.version,
"icon_resources": [(1, "images/xxx_icon.ico")],
"other_resources": [(24,1, manifest)]
}],
name='xxx',
data_files=[('imageformats',[r'C:\Python27\Lib\site-packages\PySide\plugins\imageformats\qico4.dll'])],
options={"py2exe" : {
"includes" : ["simplejson", "sip", "PySide.QtNetwork", "requests", "pysphere", "PySide.QtCore"],
"excludes" : ["Tkconstants", "Tkinter", "tcl"],
"dll_excludes" : ['w9xpopen.exe', 'MSVCP90.dll'],
"bundle_files" : 1,
"optimize": 2,
"compressed": True }},
zipfile=None,
**py2exe_options)
Inside of src/main.py I have:
...
webAppDir = unzipResources()
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
app.setWindowIcon(QtGui.QIcon('%s/images/xxx_icon.ico' % webAppDir))
window.setWindowIcon(QtGui.QIcon('%s/images/xxx_icon.ico' % webAppDir))
...
If I change my bundle_files to 2 and have the dll_excludes and data_files suggested over here, it works and the icon appears in the taskbar and window bar:
https://stackoverflow.com/a/5643540/901641
Unforuntately, setting bundle_files to 2 means python isn't included in the exe, and so it requires the user to have python installed, which is unacceptable. So, why isn't the window bar and taskbar icon being set properly?
Edit: Further experimentation has shown that simply setting bundle_files to 3 makes this work, without changing either dll_excludes or data_files. Unfortunately, again, this means that Python isn't included in the exe, and so it requires the user to have Python installed, which is again unacceptable.
Edit 2x: I've tried extending py2exe by adding the following to setup.py:
from py2exe.build_exe import py2exe as build_exe
class Extender(build_exe):
def copy_dlls(self, dlls):
dlls.append(r'C:\Python27\Lib\site-packages\PySide\plugins\imageformats\qico4.dll')
build_exe.copy_dlls(self, dlls)
py2exe_options={'cmdclass':{'py2exe':Extender},}
It copied the dll into the temporary build directory but it didn't actually make the image appear.