From f59a4f85dbbe820e4dfe12437941dd5c6880f2db Mon Sep 17 00:00:00 2001 From: ghost43 Date: Sun, 9 Dec 2018 05:09:28 +0100 Subject: [PATCH] win/mac build: strip parts of pyqt5 from binaries to reduce size (#4901) When bumping pyinstaller to 3.4, binary sizes had increased drastically. The main reason seems to be that pyinstaller is pulling in "all" of qt. based on Electron-Cash/Electron-Cash@4b0996959420dfca3d53f178d86205616d8c568b --- contrib/build-wine/deterministic.spec | 18 ++++++++++++++++++ contrib/osx/osx.spec | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/contrib/build-wine/deterministic.spec b/contrib/build-wine/deterministic.spec index dafda1c99..b208ee169 100644 --- a/contrib/build-wine/deterministic.spec +++ b/contrib/build-wine/deterministic.spec @@ -78,6 +78,24 @@ for d in a.datas: a.datas.remove(d) break +# 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("Removing Qt binaries:", *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("Removing Qt datas:", *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) + # hotfix for #3171 (pre-Win10 binaries) a.binaries = [x for x in a.binaries if not x[1].lower().startswith(r'c:\windows')] diff --git a/contrib/osx/osx.spec b/contrib/osx/osx.spec index ac9c07a0e..7b56d6f46 100644 --- a/contrib/osx/osx.spec +++ b/contrib/osx/osx.spec @@ -81,6 +81,15 @@ for d in a.datas: a.datas.remove(d) break +# Strip out parts of Qt that we never use. Reduces binary size by tens of MBs. see #4815 +qt_bins2remove=('qtweb', 'qt3d', 'qtgame', 'qtdesigner', 'qtquick', 'qtlocation', 'qttest', 'qtxml') +print("Removing Qt binaries:", *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) + pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz,