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