I'm trying to shrink the size of my python exe file, I've been looking around but I can't seem to find a good answer for removing extra modules. At the moment, I'm discovering that it's deleting modules I need instead of the ones I'm telling it to. The documentation is rather unhelpful and neither are examples I've found so far.
My spec file:
a = Analysis(['D:\<path>\<scriptName>.py'],
pathex=['c:\bin\pyinstaller-2.0'],
hiddenimports=[],
hookspath=None,
)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.zipfiles,
a.scripts,
a.binaries,
a.datas + [('data/Sounds/Cycle.wav', 'D:\<path>\data\Sounds\Cycle.wav','DATA'),
('data/Sounds/Hold.wav', 'D:\<path>\data\Sounds\Hold.wav','DATA'),
('data/Sounds/Timer.wav', 'D:\<path>\data\Sounds\Timer.wav','DATA'),
('data/Sounds/Warn.wav', 'D:\<path>\data\Sounds\Warn.wav','DATA'),
],
name=os.path.join('dist', 'timer.exe'),
debug=False,
strip=False,
upx=False,
icon=r"D:<path>Icon.ico",
console=True )
Now, I want to start excluding things, but there doesn't seem to be a very explanation of how to exclude things.
These are things I had excluded when using py2exe:
'win32', 'unittest', _ssl, 'python25.dll', 'w9xpopen.exe', 'wx'
'python25.dll', 'API*', 'KERNALBASE.dll', 'DEVOBJ.dll','CRMGR32.dll',
'POWERPROF.dll', 'msvcm90.dll', 'msvcp90.dll', 'msvcr90.dll'
Though if I add any of these into the a.binaries as
a.binaries -[('wx')],
it deletes the PyQt4.dll files instead. Same holds true for the others. I do not follow that logic. I would think, at the very least, if it couldn't find them in the first place it would just skip over them instead of deleting other things.
py2exe makes me a 26mb files + three files (exe, library.zip, and w9xpopen.exe)
pyInstaller makes me an 11mb file, and one file.
I feel I can make it smaller, but this excludes thing is confusing me. It straight up ignores the msv dll files and puts them in anyway.
Using Python 2.7, PyQt4 4.9.x
See Question&Answers more detail:
os