PyInstaller misleadingly defines flag for the user to include an .icns
but it actually does nothing, as documented:
-i FILE.ICO, -i FILE.EXE,ID, -i FILE.ICNS, --icon=FILE.ICO, --icon=FILE.EXE,ID, --icon=FILE.ICNS
If FILE is an .ico file, add the icon to the final executable. Otherwise, the syntax 'file.exe,id' to extract the icon with the specified id from file.exe and add it to the final executable. If FILE is an .icns file, add the icon to the final .app bundle on Mac OS X (for Mac not yet implemented)
So that was rather hopeless. The next best way is surely to replace the default PyInstaller icon with my very own, surely. I do this in a script:
pyinstaller -y --windowed --name="foobar" --workpath="target/build" --distpath="target/dist" *.spec
# Update the icon: PyInstaller's -i switch is not implemented for Mac
cp "path/to/icon.icns" "target/dist/foobar.app/Contents/Resources/icon-windowed.icns"
However, I found that doing this programmatically causes Finder to get confused because it already registered the application as having the original Python icon. Yet, it cannot be found. Thus the application launches with no icon at all.
How can I set the icon properly?