electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

deterministic.spec (5938B)


      1 # -*- mode: python -*-
      2 
      3 from PyInstaller.utils.hooks import collect_data_files, collect_submodules, collect_dynamic_libs
      4 
      5 import sys
      6 for i, x in enumerate(sys.argv):
      7     if x == '--name':
      8         cmdline_name = sys.argv[i+1]
      9         break
     10 else:
     11     raise Exception('no name')
     12 
     13 home = 'C:\\electrum\\'
     14 
     15 # see https://github.com/pyinstaller/pyinstaller/issues/2005
     16 hiddenimports = []
     17 hiddenimports += collect_submodules('pkg_resources')  # workaround for https://github.com/pypa/setuptools/issues/1963
     18 hiddenimports += collect_submodules('trezorlib')
     19 hiddenimports += collect_submodules('safetlib')
     20 hiddenimports += collect_submodules('btchip')
     21 hiddenimports += collect_submodules('keepkeylib')
     22 hiddenimports += collect_submodules('websocket')
     23 hiddenimports += collect_submodules('ckcc')
     24 hiddenimports += collect_submodules('bitbox02')
     25 hiddenimports += ['PyQt5.QtPrintSupport']  # needed by Revealer
     26 
     27 
     28 binaries = []
     29 
     30 # Workaround for "Retro Look":
     31 binaries += [b for b in collect_dynamic_libs('PyQt5') if 'qwindowsvista' in b[0]]
     32 
     33 binaries += [('C:/tmp/libsecp256k1-0.dll', '.')]
     34 binaries += [('C:/tmp/libusb-1.0.dll', '.')]
     35 binaries += [('C:/tmp/libzbar-0.dll', '.')]
     36 
     37 datas = [
     38     (home+'electrum/*.json', 'electrum'),
     39     (home+'electrum/lnwire/*.csv', 'electrum/lnwire'),
     40     (home+'electrum/wordlist/english.txt', 'electrum/wordlist'),
     41     (home+'electrum/locale', 'electrum/locale'),
     42     (home+'electrum/plugins', 'electrum/plugins'),
     43     (home+'electrum/gui/icons', 'electrum/gui/icons'),
     44 ]
     45 datas += collect_data_files('trezorlib')
     46 datas += collect_data_files('safetlib')
     47 datas += collect_data_files('btchip')
     48 datas += collect_data_files('keepkeylib')
     49 datas += collect_data_files('ckcc')
     50 datas += collect_data_files('bitbox02')
     51 
     52 # We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
     53 a = Analysis([home+'run_electrum',
     54               home+'electrum/gui/qt/main_window.py',
     55               home+'electrum/gui/text.py',
     56               home+'electrum/util.py',
     57               home+'electrum/wallet.py',
     58               home+'electrum/simple_config.py',
     59               home+'electrum/bitcoin.py',
     60               home+'electrum/dnssec.py',
     61               home+'electrum/commands.py',
     62               home+'electrum/plugins/cosigner_pool/qt.py',
     63               home+'electrum/plugins/email_requests/qt.py',
     64               home+'electrum/plugins/trezor/qt.py',
     65               home+'electrum/plugins/safe_t/client.py',
     66               home+'electrum/plugins/safe_t/qt.py',
     67               home+'electrum/plugins/keepkey/qt.py',
     68               home+'electrum/plugins/ledger/qt.py',
     69               home+'electrum/plugins/coldcard/qt.py',
     70               #home+'packages/requests/utils.py'
     71               ],
     72              binaries=binaries,
     73              datas=datas,
     74              #pathex=[home+'lib', home+'gui', home+'plugins'],
     75              hiddenimports=hiddenimports,
     76              hookspath=[])
     77 
     78 
     79 # http://stackoverflow.com/questions/19055089/pyinstaller-onefile-warning-pyconfig-h-when-importing-scipy-or-scipy-signal
     80 for d in a.datas:
     81     if 'pyconfig' in d[0]:
     82         a.datas.remove(d)
     83         break
     84 
     85 # Strip out parts of Qt that we never use. Reduces binary size by tens of MBs. see #4815
     86 qt_bins2remove=('qt5web', 'qt53d', 'qt5game', 'qt5designer', 'qt5quick',
     87                 'qt5location', 'qt5test', 'qt5xml', r'pyqt5\qt\qml\qtquick')
     88 print("Removing Qt binaries:", *qt_bins2remove)
     89 for x in a.binaries.copy():
     90     for r in qt_bins2remove:
     91         if x[0].lower().startswith(r):
     92             a.binaries.remove(x)
     93             print('----> Removed x =', x)
     94 
     95 qt_data2remove=(r'pyqt5\qt\translations\qtwebengine_locales', )
     96 print("Removing Qt datas:", *qt_data2remove)
     97 for x in a.datas.copy():
     98     for r in qt_data2remove:
     99         if x[0].lower().startswith(r):
    100             a.datas.remove(x)
    101             print('----> Removed x =', x)
    102 
    103 # hotfix for #3171 (pre-Win10 binaries)
    104 a.binaries = [x for x in a.binaries if not x[1].lower().startswith(r'c:\windows')]
    105 
    106 pyz = PYZ(a.pure)
    107 
    108 
    109 #####
    110 # "standalone" exe with all dependencies packed into it
    111 
    112 exe_standalone = EXE(
    113     pyz,
    114     a.scripts,
    115     a.binaries,
    116     a.datas,
    117     name=os.path.join('build\\pyi.win32\\electrum', cmdline_name + ".exe"),
    118     debug=False,
    119     strip=None,
    120     upx=False,
    121     icon=home+'electrum/gui/icons/electrum.ico',
    122     console=False)
    123     # 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
    124 
    125 exe_portable = EXE(
    126     pyz,
    127     a.scripts,
    128     a.binaries,
    129     a.datas + [ ('is_portable', 'README.md', 'DATA' ) ],
    130     name=os.path.join('build\\pyi.win32\\electrum', cmdline_name + "-portable.exe"),
    131     debug=False,
    132     strip=None,
    133     upx=False,
    134     icon=home+'electrum/gui/icons/electrum.ico',
    135     console=False)
    136 
    137 #####
    138 # exe and separate files that NSIS uses to build installer "setup" exe
    139 
    140 exe_inside_setup_noconsole = EXE(
    141     pyz,
    142     a.scripts,
    143     exclude_binaries=True,
    144     name=os.path.join('build\\pyi.win32\\electrum', cmdline_name),
    145     debug=False,
    146     strip=None,
    147     upx=False,
    148     icon=home+'electrum/gui/icons/electrum.ico',
    149     console=False)
    150 
    151 exe_inside_setup_console = EXE(
    152     pyz,
    153     a.scripts,
    154     exclude_binaries=True,
    155     name=os.path.join('build\\pyi.win32\\electrum', cmdline_name+"-debug"),
    156     debug=False,
    157     strip=None,
    158     upx=False,
    159     icon=home+'electrum/gui/icons/electrum.ico',
    160     console=True)
    161 
    162 coll = COLLECT(
    163     exe_inside_setup_noconsole,
    164     exe_inside_setup_console,
    165     a.binaries,
    166     a.zipfiles,
    167     a.datas,
    168     strip=None,
    169     upx=True,
    170     debug=False,
    171     icon=home+'electrum/gui/icons/electrum.ico',
    172     console=False,
    173     name=os.path.join('dist', 'electrum'))