electrum-bitcoinprivate/setup-release.py

94 lines
2.8 KiB
Python
Raw Normal View History

2012-07-22 16:19:25 -07:00
"""
py2app/py2exe build script for Electrum Litecoin
Usage (Mac OS X):
python setup.py py2app
Usage (Windows):
python setup.py py2exe
"""
from setuptools import setup
2013-11-12 19:33:47 -08:00
import os
import re
import shutil
import sys
2012-07-22 16:19:25 -07:00
from lib.util import print_error
2013-11-12 19:33:47 -08:00
from lib.version import ELECTRUM_VERSION as version
2012-07-22 16:19:25 -07:00
name = "Electrum"
mainscript = 'electrum'
2013-11-12 19:33:47 -08:00
if sys.version_info[:3] < (2, 6, 0):
2012-07-22 16:19:25 -07:00
print_error("Error: " + name + " requires Python version >= 2.6.0...")
sys.exit(1)
if sys.platform == 'darwin':
from plistlib import Plist
plist = Plist.fromFile('Info.plist')
plist.update(dict(CFBundleIconFile='electrum.icns'))
2012-07-22 16:19:25 -07:00
shutil.copy(mainscript, mainscript + '.py')
mainscript += '.py'
extra_options = dict(
setup_requires=['py2app'],
app=[mainscript],
options=dict(py2app=dict(argv_emulation=True,
2014-01-05 00:19:23 -08:00
includes=['PyQt4.QtCore', 'PyQt4.QtGui', 'PyQt4.QtWebKit', 'PyQt4.QtNetwork', 'sip'],
2013-11-12 19:33:47 -08:00
packages=['lib', 'gui', 'plugins'],
2012-07-22 16:19:25 -07:00
iconfile='electrum.icns',
2013-11-13 03:59:36 -08:00
plist=plist,
2012-12-09 04:04:01 -08:00
resources=["data", "icons"])),
2012-07-22 16:19:25 -07:00
)
elif sys.platform == 'win32':
extra_options = dict(
setup_requires=['py2exe'],
app=[mainscript],
)
else:
extra_options = dict(
# Normally unix-like platforms will use "setup.py install"
# and install the main script as such
scripts=[mainscript],
)
setup(
2013-11-12 19:33:47 -08:00
name=name,
version=version,
2012-07-22 16:19:25 -07:00
**extra_options
)
from distutils import dir_util
2012-07-22 16:19:25 -07:00
if sys.platform == 'darwin':
# Remove the copied py file
os.remove(mainscript)
resource = "dist/" + name + ".app/Contents/Resources/"
dir_util.copy_tree("locale", resource + "locale/")
# Try to locate qt_menu
# Let's try the port version first!
if os.path.isfile("/opt/local/lib/Resources/qt_menu.nib"):
2013-11-12 19:33:47 -08:00
qt_menu_location = "/opt/local/lib/Resources/qt_menu.nib"
else:
2013-11-12 19:33:47 -08:00
# No dice? Then let's try the brew version
if os.path.exists("/usr/local/Cellar"):
qt_menu_location = os.popen("find /usr/local/Cellar -name qt_menu.nib | tail -n 1").read()
# no brew, check /opt/local
else:
qt_menu_location = os.popen("find /opt/local -name qt_menu.nib | tail -n 1").read()
2013-11-12 19:33:47 -08:00
qt_menu_location = re.sub('\n', '', qt_menu_location)
2013-11-12 19:33:47 -08:00
if (len(qt_menu_location) == 0):
print "Sorry couldn't find your qt_menu.nib this probably won't work"
else:
2013-11-12 19:33:47 -08:00
print "Found your qib: " + qt_menu_location
2012-07-22 16:19:25 -07:00
# Need to include a copy of qt_menu.nib
shutil.copytree(qt_menu_location, resource + "qt_menu.nib")
2012-07-22 16:21:31 -07:00
# Need to touch qt.conf to avoid loading 2 sets of Qt libraries
2012-07-22 16:19:25 -07:00
fname = resource + "qt.conf"
with file(fname, 'a'):
os.utime(fname, None)