2012-12-09 10:40:31 +01:00
# -*- mode: python -*-
2013-03-16 21:13:55 +01:00
2018-02-21 02:00:21 +01:00
from PyInstaller.utils.hooks import collect_data_files, collect_submodules, collect_dynamic_libs
2017-10-17 04:04:15 +02:00
2017-03-09 10:20:27 +01:00
import sys
for i, x in enumerate(sys.argv):
if x == '--name' :
cmdline_name = sys.argv[i+1]
break
else:
2018-04-07 17:10:30 +02:00
raise Exception('no name' )
2017-03-09 10:20:27 +01:00
2018-12-09 07:17:37 +01:00
PYHOME = 'c:/python3'
2017-03-09 10:20:27 +01:00
2015-10-05 16:43:10 +00:00
home = 'C:\\electrum\\'
2017-10-17 04:04:15 +02:00
# see https://github.com/pyinstaller/pyinstaller/issues/2005
hiddenimports = []
hiddenimports += collect_submodules('trezorlib' )
2018-07-25 20:07:39 +02:00
hiddenimports += collect_submodules('safetlib' )
2017-10-17 04:04:15 +02:00
hiddenimports += collect_submodules('btchip' )
hiddenimports += collect_submodules('keepkeylib' )
2018-03-03 19:36:05 +01:00
hiddenimports += collect_submodules('websocket' )
2018-06-26 22:33:04 +02:00
hiddenimports += collect_submodules('ckcc' )
2019-03-22 15:23:43 +01:00
hiddenimports += ['PyQt5.QtPrintSupport' ] # needed by Revealer
2017-10-17 04:04:15 +02:00
2019-01-31 20:58:04 +01:00
# safetlib imports PyQt5.Qt. We use a local updated copy of pinmatrix.py until they
# release a new version that includes https://github.com/archos-safe-t/python-safet/commit/b1eab3dba4c04fdfc1fcf17b66662c28c5f2380e
hiddenimports.remove('safetlib.qt.pinmatrix' )
2018-02-21 02:00:21 +01:00
# Add libusb binary
2018-03-31 00:14:26 +02:00
binaries = [(PYHOME+" / l i b u s b - 1 . 0 . d l l " , " . " )]
2018-02-21 02:00:21 +01:00
# Workaround for "Retro Look":
binaries += [b for b in collect_dynamic_libs('PyQt5' ) if 'qwindowsvista' in b[0]]
2018-05-25 15:42:45 +02:00
binaries += [('C:/tmp/libsecp256k1.dll' , '.' )]
2017-10-17 04:04:15 +02:00
datas = [
2018-07-11 17:38:47 +02:00
(home+'electrum/*.json' , 'electrum' ),
(home+'electrum/wordlist/english.txt' , 'electrum/wordlist' ),
(home+'electrum/locale' , 'electrum/locale' ),
2018-09-04 17:06:42 +02:00
(home+'electrum/plugins' , 'electrum/plugins' ),
('C:\\Program Files (x86)\\ZBar\\bin\\' , '.' ),
2019-02-07 18:57:25 +01:00
(home+'electrum/gui/icons' , 'electrum/gui/icons' ),
2017-10-17 04:04:15 +02:00
]
datas += collect_data_files('trezorlib' )
2018-07-25 20:07:39 +02:00
datas += collect_data_files('safetlib' )
2017-10-17 04:04:15 +02:00
datas += collect_data_files('btchip' )
datas += collect_data_files('keepkeylib' )
2018-06-26 22:33:04 +02:00
datas += collect_data_files('ckcc' )
2017-10-17 04:04:15 +02:00
2013-03-16 21:13:55 +01:00
# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
2018-07-11 17:38:47 +02:00
a = Analysis([home+'run_electrum' ,
home+'electrum/gui/qt/main_window.py' ,
home+'electrum/gui/text.py' ,
home+'electrum/util.py' ,
home+'electrum/wallet.py' ,
home+'electrum/simple_config.py' ,
home+'electrum/bitcoin.py' ,
home+'electrum/dnssec.py' ,
home+'electrum/commands.py' ,
home+'electrum/plugins/cosigner_pool/qt.py' ,
home+'electrum/plugins/email_requests/qt.py' ,
home+'electrum/plugins/trezor/qt.py' ,
2018-07-25 20:07:39 +02:00
home+'electrum/plugins/safe_t/client.py' ,
home+'electrum/plugins/safe_t/qt.py' ,
2018-07-11 17:38:47 +02:00
home+'electrum/plugins/keepkey/qt.py' ,
home+'electrum/plugins/ledger/qt.py' ,
2018-06-26 22:33:04 +02:00
home+'electrum/plugins/coldcard/qt.py' ,
2017-08-07 20:06:43 +02:00
#home+'packages/requests/utils.py'
2013-03-16 21:13:55 +01:00
],
2018-02-21 02:00:21 +01:00
binaries=binaries,
2017-10-17 04:04:15 +02:00
datas=datas,
2017-08-07 20:06:43 +02:00
#pathex=[home+'lib', home+'gui', home+'plugins'],
2017-10-17 04:04:15 +02:00
hiddenimports=hiddenimports,
2015-10-05 16:43:10 +00:00
hookspath=[])
2013-03-16 21:13:55 +01:00
2017-03-09 09:17:14 +01:00
# http://stackoverflow.com/questions/19055089/pyinstaller-onefile-warning-pyconfig-h-when-importing-scipy-or-scipy-signal
for d in a.datas:
2018-07-11 17:38:47 +02:00
if 'pyconfig' in d[0]:
2017-03-09 09:17:14 +01:00
a.datas.remove(d)
break
2018-12-09 05:09:28 +01:00
# Strip out parts of Qt that we never use. Reduces binary size by tens of MBs. see #4815
qt_bins2remove=('qt5web' , 'qt53d' , 'qt5game' , 'qt5designer' , 'qt5quick' ,
'qt5location' , 'qt5test' , 'qt5xml' , r'pyqt5\qt\qml\qtquick' )
print(" R e m o v i n g Q t b i n a r i e s : " , *qt_bins2remove)
for x in a.binaries.copy():
for r in qt_bins2remove:
if x[0].lower().startswith(r):
a.binaries.remove(x)
print('----> Removed x =' , x)
qt_data2remove=(r'pyqt5\qt\translations\qtwebengine_locales' , )
print(" R e m o v i n g Q t d a t a s : " , *qt_data2remove)
for x in a.datas.copy():
for r in qt_data2remove:
if x[0].lower().startswith(r):
a.datas.remove(x)
print('----> Removed x =' , x)
2017-11-02 19:11:00 +01:00
# hotfix for #3171 (pre-Win10 binaries)
a.binaries = [x for x in a.binaries if not x[1].lower().startswith(r'c:\windows' )]
2013-03-16 21:13:55 +01:00
pyz = PYZ(a.pure)
2017-11-07 03:43:10 +01:00
#####
# "standalone" exe with all dependencies packed into it
exe_standalone = EXE(
2017-11-28 18:20:14 +01:00
pyz,
a.scripts,
a.binaries,
2018-07-11 17:38:47 +02:00
a.datas,
2017-11-28 18:20:14 +01:00
name=os.path.join('build\\pyi.win32\\electrum' , cmdline_name + " . e x e " ),
debug=False,
strip=None,
upx=False,
2019-02-07 18:57:25 +01:00
icon=home+'electrum/gui/icons/electrum.ico' ,
2017-11-28 18:20:14 +01:00
console=False)
# console=True makes an annoying black box pop up, but it does make Electrum output command line commands, with this turned off no output will be given but commands can still be used
exe_portable = EXE(
pyz,
a.scripts,
a.binaries,
a.datas + [ ('is_portable' , 'README.md' , 'DATA' ) ],
name=os.path.join('build\\pyi.win32\\electrum' , cmdline_name + " - p o r t a b l e . e x e " ),
debug=False,
strip=None,
upx=False,
2019-02-07 18:57:25 +01:00
icon=home+'electrum/gui/icons/electrum.ico' ,
2017-11-28 18:20:14 +01:00
console=False)
2013-03-16 21:13:55 +01:00
2017-11-07 03:43:10 +01:00
#####
# exe and separate files that NSIS uses to build installer "setup" exe
exe_dependent = EXE(
2017-11-28 18:20:14 +01:00
pyz,
a.scripts,
exclude_binaries=True,
name=os.path.join('build\\pyi.win32\\electrum' , cmdline_name),
debug=False,
strip=None,
upx=False,
2019-02-07 18:57:25 +01:00
icon=home+'electrum/gui/icons/electrum.ico' ,
2017-11-28 18:20:14 +01:00
console=False)
2017-11-07 03:43:10 +01:00
coll = COLLECT(
2017-11-28 18:20:14 +01:00
exe_dependent,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
debug=False,
2019-02-07 18:57:25 +01:00
icon=home+'electrum/gui/icons/electrum.ico' ,
2017-11-28 18:20:14 +01:00
console=False,
name=os.path.join('dist' , 'electrum' ))