Add icon back to Lite GUI. Fixes #112
[electrum-nvc.git] / setup-release.py
1 """
2 py2app/py2exe build script for Electrum Litecoin
3
4 Usage (Mac OS X):
5      python setup.py py2app
6
7 Usage (Windows):
8      python setup.py py2exe
9 """
10
11 import sys, os, shutil, re
12 from setuptools import setup
13 from lib.version import ELECTRUM_VERSION as version
14 from lib.util import print_error
15
16
17 name = "Electrum"
18 mainscript = 'electrum'
19
20 if sys.version_info[:3] < (2,6,0):
21     print_error("Error: " + name + " requires Python version >= 2.6.0...")
22     sys.exit(1)
23
24 if sys.platform == 'darwin':
25     shutil.copy(mainscript, mainscript + '.py')
26     mainscript += '.py'
27     extra_options = dict(
28         setup_requires=['py2app'],
29         app=[mainscript],
30         options=dict(py2app=dict(argv_emulation=True,
31                                  includes = ['PyQt4.QtCore','PyQt4.QtGui', 'sip'],
32                                  packages = ['lib', 'gui', 'plugins'],
33                                  iconfile='electrum.icns',
34                                  plist=dict(CFBundleIconFile='electrum.icns'),
35                                  resources=["data", "icons"])),
36     )
37 elif sys.platform == 'win32':
38     extra_options = dict(
39         setup_requires=['py2exe'],
40         app=[mainscript],
41     )
42 else:
43     extra_options = dict(
44         # Normally unix-like platforms will use "setup.py install"
45         # and install the main script as such
46         scripts=[mainscript],
47     )
48
49 setup(
50     name = name,
51     version = version,
52     **extra_options
53 )
54 from distutils import dir_util
55
56 if sys.platform == 'darwin':
57     # Remove the copied py file
58     os.remove(mainscript)
59     resource = "dist/" + name + ".app/Contents/Resources/"
60
61     dir_util.copy_tree("locale", resource + "locale/")
62     # Try to locate qt_menu
63     # Let's try the port version first!
64     if os.path.isfile("/opt/local/lib/Resources/qt_menu.nib"):
65       qt_menu_location = "/opt/local/lib/Resources/qt_menu.nib"
66     else:
67       # No dice? Then let's try the brew version
68       qt_menu_location = os.popen("find /usr/local/Cellar -name qt_menu.nib | tail -n 1").read()
69       qt_menu_location = re.sub('\n','', qt_menu_location)
70
71     if(len(qt_menu_location) == 0):
72       print "Sorry couldn't find your qt_menu.nib this probably won't work"
73     else:
74       print "Found your qib: " + qt_menu_location
75
76     # Need to include a copy of qt_menu.nib
77     shutil.copytree(qt_menu_location, resource + "qt_menu.nib")
78     # Need to touch qt.conf to avoid loading 2 sets of Qt libraries
79     fname = resource + "qt.conf"
80     with file(fname, 'a'):
81         os.utime(fname, None)