It appears py2exe has a 4-year-old bug on handling icons, but due to its description, I managed to make this workaround:
setup_dict = dict(
windows = [{'script': "script.py",
"icon_resources": [(1, "icon.ico")}],
)
setup(**setup_dict)
setup(**setup_dict)
This pretty much builds the project twice. If your project is complex and takes too long to process through py2exe, you can use this to build a dummy py file:
import tempfile
tf = tempfile.NamedTemporaryFile(delete=False)
tf.close()
setup(
windows = [{
'script': tf.name,
"icon_resources":[(1, "icon.ico")]}]
)
os.remove(tf.name)
Just don't forget to set excludes like your project, otherwise you will get your dist
folder cluttered with unwanted files.