0

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?

fatuhoku
  • 4,815
  • 3
  • 30
  • 70

1 Answers1

0

It seems like pyinstaller's options are only relevant to create the spec file. Once you have the spec file, you should edit the commands in the spec file instead of providing options to the command line, which will be ignored.

To see what the effect of these command-line options are in the spec file, you can make use of the pyi-makespec script (distributed with PyInstaller).

phfaist
  • 253
  • 4
  • 6