schmir / bbfreeze

UNMAINTAINED
http://pypi.python.org/pypi/bbfreeze/
92 stars 22 forks source link

Add icon to executables #16

Closed jsargiot closed 11 years ago

jsargiot commented 11 years ago

Added SetIcon method to Freezer to set the executable icon on windows.

The winexeutil module uses win32api so pywin32 must be installed to be able to use. The module uses the windows api to update resources on the executables. For now it only edits the icons... but in the future it may modify other resources.

Also added a test which is basically similar to test_guiscript.py but adds an icon.

schmir commented 11 years ago

Thanks for this pull request. There is a problem however. The link method doesn't handle the non-win32 case when the linkmethod is "loader". Here's a short script to reproduce the problem

import sys
if getattr(sys, "frozen", False):
    print "hello world"
else:
    from bbfreeze import Freezer
    f=Freezer()
    f.linkmethod = "loader"
    f.addScript("hello-world.py")
    f()

On linux it bails out with:

The following eggs are being used:
distribute 0.6.34 (/home/ralf/ve/dev/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg)
==================================================
Copying /home/ralf/ve/dev/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg to /home/ralf/bbfreeze/dist/distribute-0.6.34-py2.7.egg
Traceback (most recent call last):
  File "hello-world.py", line 9, in 
    f()
  File "/home/ralf/bbfreeze/bbfreeze/freezer.py", line 622, in __call__
    m(x)
  File "/home/ralf/bbfreeze/bbfreeze/freezer.py", line 726, in _handle_Script
    self.link(self.zipfilepath, os.path.join(self.distdir, exename), gui_only=gui_only)
  File "/home/ralf/bbfreeze/bbfreeze/freezer.py", line 767, in link
    os.chmod(dst, 0755)
OSError: [Errno 2] No such file or directory: '/home/ralf/bbfreeze/dist/py'
jsargiot commented 11 years ago

Ups! So sorry about that. I've simplified the change to keep the original code untouched... I've also tested the snippet you mention and it works... Tested on ubuntu and windows 7

schmir commented 11 years ago

I've merged it.

Many thanks.