pyinstaller build: better parameterise .spec
This commit is contained in:
@@ -4,16 +4,20 @@ from PyInstaller.utils.hooks import collect_data_files, collect_submodules, coll
|
|||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
PYPKG="electrum"
|
||||||
|
MAIN_SCRIPT="run_electrum"
|
||||||
|
PROJECT_ROOT = "C:/electrum"
|
||||||
|
ICONS_FILE=f"{PROJECT_ROOT}/{PYPKG}/gui/icons/electrum.ico"
|
||||||
|
|
||||||
cmdline_name = os.environ.get("ELECTRUM_CMDLINE_NAME")
|
cmdline_name = os.environ.get("ELECTRUM_CMDLINE_NAME")
|
||||||
if not cmdline_name:
|
if not cmdline_name:
|
||||||
raise Exception('no name')
|
raise Exception('no name')
|
||||||
|
|
||||||
home = 'C:\\electrum\\'
|
|
||||||
|
|
||||||
# see https://github.com/pyinstaller/pyinstaller/issues/2005
|
# see https://github.com/pyinstaller/pyinstaller/issues/2005
|
||||||
hiddenimports = []
|
hiddenimports = []
|
||||||
hiddenimports += collect_submodules('pkg_resources') # workaround for https://github.com/pypa/setuptools/issues/1963
|
hiddenimports += collect_submodules('pkg_resources') # workaround for https://github.com/pypa/setuptools/issues/1963
|
||||||
hiddenimports += collect_submodules('electrum.plugins')
|
hiddenimports += collect_submodules(f"{PYPKG}.plugins")
|
||||||
|
|
||||||
|
|
||||||
binaries = []
|
binaries = []
|
||||||
@@ -21,18 +25,18 @@ binaries = []
|
|||||||
# Workaround for "Retro Look":
|
# Workaround for "Retro Look":
|
||||||
binaries += [b for b in collect_dynamic_libs('PyQt5') if 'qwindowsvista' in b[0]]
|
binaries += [b for b in collect_dynamic_libs('PyQt5') if 'qwindowsvista' in b[0]]
|
||||||
|
|
||||||
binaries += [(home+'electrum/*.dll', '.')]
|
binaries += [(f"{PROJECT_ROOT}/{PYPKG}/*.dll", '.')]
|
||||||
|
|
||||||
datas = [
|
datas = [
|
||||||
(home+'electrum/*.json', 'electrum'),
|
(f"{PROJECT_ROOT}/{PYPKG}/*.json", PYPKG),
|
||||||
(home+'electrum/lnwire/*.csv', 'electrum/lnwire'),
|
(f"{PROJECT_ROOT}/{PYPKG}/lnwire/*.csv", f"{PYPKG}/lnwire"),
|
||||||
(home+'electrum/wordlist/english.txt', 'electrum/wordlist'),
|
(f"{PROJECT_ROOT}/{PYPKG}/wordlist/english.txt", f"{PYPKG}/wordlist"),
|
||||||
(home+'electrum/wordlist/slip39.txt', 'electrum/wordlist'),
|
(f"{PROJECT_ROOT}/{PYPKG}/wordlist/slip39.txt", f"{PYPKG}/wordlist"),
|
||||||
(home+'electrum/locale', 'electrum/locale'),
|
(f"{PROJECT_ROOT}/{PYPKG}/locale", f"{PYPKG}/locale"),
|
||||||
(home+'electrum/plugins', 'electrum/plugins'),
|
(f"{PROJECT_ROOT}/{PYPKG}/plugins", f"{PYPKG}/plugins"),
|
||||||
(home+'electrum/gui/icons', 'electrum/gui/icons'),
|
(f"{PROJECT_ROOT}/{PYPKG}/gui/icons", f"{PYPKG}/gui/icons"),
|
||||||
]
|
]
|
||||||
datas += collect_data_files('electrum.plugins')
|
datas += collect_data_files(f"{PYPKG}.plugins")
|
||||||
datas += collect_data_files('trezorlib') # TODO is this needed? and same question for other hww libs
|
datas += collect_data_files('trezorlib') # TODO is this needed? and same question for other hww libs
|
||||||
datas += collect_data_files('safetlib')
|
datas += collect_data_files('safetlib')
|
||||||
datas += collect_data_files('btchip')
|
datas += collect_data_files('btchip')
|
||||||
@@ -41,20 +45,19 @@ datas += collect_data_files('ckcc')
|
|||||||
datas += collect_data_files('bitbox02')
|
datas += collect_data_files('bitbox02')
|
||||||
|
|
||||||
# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
|
# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
|
||||||
a = Analysis([home+'run_electrum',
|
a = Analysis([f"{PROJECT_ROOT}/{MAIN_SCRIPT}",
|
||||||
home+'electrum/gui/qt/main_window.py',
|
f"{PROJECT_ROOT}/{PYPKG}/gui/qt/main_window.py",
|
||||||
home+'electrum/gui/qt/qrreader/qtmultimedia/camera_dialog.py',
|
f"{PROJECT_ROOT}/{PYPKG}/gui/qt/qrreader/qtmultimedia/camera_dialog.py",
|
||||||
home+'electrum/gui/text.py',
|
f"{PROJECT_ROOT}/{PYPKG}/gui/text.py",
|
||||||
home+'electrum/util.py',
|
f"{PROJECT_ROOT}/{PYPKG}/util.py",
|
||||||
home+'electrum/wallet.py',
|
f"{PROJECT_ROOT}/{PYPKG}/wallet.py",
|
||||||
home+'electrum/simple_config.py',
|
f"{PROJECT_ROOT}/{PYPKG}/simple_config.py",
|
||||||
home+'electrum/bitcoin.py',
|
f"{PROJECT_ROOT}/{PYPKG}/bitcoin.py",
|
||||||
home+'electrum/dnssec.py',
|
f"{PROJECT_ROOT}/{PYPKG}/dnssec.py",
|
||||||
home+'electrum/commands.py',
|
f"{PROJECT_ROOT}/{PYPKG}/commands.py",
|
||||||
],
|
],
|
||||||
binaries=binaries,
|
binaries=binaries,
|
||||||
datas=datas,
|
datas=datas,
|
||||||
#pathex=[home+'lib', home+'gui', home+'plugins'],
|
|
||||||
hiddenimports=hiddenimports,
|
hiddenimports=hiddenimports,
|
||||||
hookspath=[])
|
hookspath=[])
|
||||||
|
|
||||||
@@ -105,11 +108,11 @@ exe_standalone = EXE(
|
|||||||
a.scripts,
|
a.scripts,
|
||||||
a.binaries,
|
a.binaries,
|
||||||
a.datas,
|
a.datas,
|
||||||
name=os.path.join('build\\pyi.win32\\electrum', cmdline_name + ".exe"),
|
name=os.path.join("build", "pyi.win32", PYPKG, f"{cmdline_name}.exe"),
|
||||||
debug=False,
|
debug=False,
|
||||||
strip=None,
|
strip=None,
|
||||||
upx=False,
|
upx=False,
|
||||||
icon=home+'electrum/gui/icons/electrum.ico',
|
icon=ICONS_FILE,
|
||||||
console=False)
|
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
|
# 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
|
||||||
|
|
||||||
@@ -118,11 +121,11 @@ exe_portable = EXE(
|
|||||||
a.scripts,
|
a.scripts,
|
||||||
a.binaries,
|
a.binaries,
|
||||||
a.datas + [('is_portable', 'README.md', 'DATA')],
|
a.datas + [('is_portable', 'README.md', 'DATA')],
|
||||||
name=os.path.join('build\\pyi.win32\\electrum', cmdline_name + "-portable.exe"),
|
name=os.path.join("build", "pyi.win32", PYPKG, f"{cmdline_name}-portable.exe"),
|
||||||
debug=False,
|
debug=False,
|
||||||
strip=None,
|
strip=None,
|
||||||
upx=False,
|
upx=False,
|
||||||
icon=home+'electrum/gui/icons/electrum.ico',
|
icon=ICONS_FILE,
|
||||||
console=False)
|
console=False)
|
||||||
|
|
||||||
#####
|
#####
|
||||||
@@ -132,22 +135,22 @@ exe_inside_setup_noconsole = EXE(
|
|||||||
pyz,
|
pyz,
|
||||||
a.scripts,
|
a.scripts,
|
||||||
exclude_binaries=True,
|
exclude_binaries=True,
|
||||||
name=os.path.join('build\\pyi.win32\\electrum', cmdline_name),
|
name=os.path.join("build", "pyi.win32", PYPKG, f"{cmdline_name}.exe"),
|
||||||
debug=False,
|
debug=False,
|
||||||
strip=None,
|
strip=None,
|
||||||
upx=False,
|
upx=False,
|
||||||
icon=home+'electrum/gui/icons/electrum.ico',
|
icon=ICONS_FILE,
|
||||||
console=False)
|
console=False)
|
||||||
|
|
||||||
exe_inside_setup_console = EXE(
|
exe_inside_setup_console = EXE(
|
||||||
pyz,
|
pyz,
|
||||||
a.scripts,
|
a.scripts,
|
||||||
exclude_binaries=True,
|
exclude_binaries=True,
|
||||||
name=os.path.join('build\\pyi.win32\\electrum', cmdline_name+"-debug"),
|
name=os.path.join("build", "pyi.win32", PYPKG, f"{cmdline_name}-debug.exe"),
|
||||||
debug=False,
|
debug=False,
|
||||||
strip=None,
|
strip=None,
|
||||||
upx=False,
|
upx=False,
|
||||||
icon=home+'electrum/gui/icons/electrum.ico',
|
icon=ICONS_FILE,
|
||||||
console=True)
|
console=True)
|
||||||
|
|
||||||
coll = COLLECT(
|
coll = COLLECT(
|
||||||
@@ -159,6 +162,6 @@ coll = COLLECT(
|
|||||||
strip=None,
|
strip=None,
|
||||||
upx=True,
|
upx=True,
|
||||||
debug=False,
|
debug=False,
|
||||||
icon=home+'electrum/gui/icons/electrum.ico',
|
icon=ICONS_FILE,
|
||||||
console=False,
|
console=False,
|
||||||
name=os.path.join('dist', 'electrum'))
|
name=os.path.join('dist', PYPKG))
|
||||||
|
|||||||
@@ -4,35 +4,35 @@ from PyInstaller.utils.hooks import collect_data_files, collect_submodules, coll
|
|||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
PACKAGE='Electrum'
|
PACKAGE_NAME='Electrum.app'
|
||||||
PYPKG='electrum'
|
PYPKG='electrum'
|
||||||
MAIN_SCRIPT='run_electrum'
|
MAIN_SCRIPT='run_electrum'
|
||||||
ICONS_FILE=PYPKG + '/gui/icons/electrum.icns'
|
PROJECT_ROOT = os.path.abspath(".")
|
||||||
|
ICONS_FILE=f"{PROJECT_ROOT}/{PYPKG}/gui/icons/electrum.icns"
|
||||||
|
|
||||||
|
|
||||||
VERSION = os.environ.get("ELECTRUM_VERSION")
|
VERSION = os.environ.get("ELECTRUM_VERSION")
|
||||||
if not VERSION:
|
if not VERSION:
|
||||||
raise Exception('no version')
|
raise Exception('no version')
|
||||||
|
|
||||||
electrum = os.path.abspath(".") + "/"
|
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
|
||||||
# see https://github.com/pyinstaller/pyinstaller/issues/2005
|
# see https://github.com/pyinstaller/pyinstaller/issues/2005
|
||||||
hiddenimports = []
|
hiddenimports = []
|
||||||
hiddenimports += collect_submodules('pkg_resources') # workaround for https://github.com/pypa/setuptools/issues/1963
|
hiddenimports += collect_submodules('pkg_resources') # workaround for https://github.com/pypa/setuptools/issues/1963
|
||||||
hiddenimports += collect_submodules('electrum.plugins')
|
hiddenimports += collect_submodules(f"{PYPKG}.plugins")
|
||||||
|
|
||||||
|
|
||||||
datas = [
|
datas = [
|
||||||
(electrum + PYPKG + '/*.json', PYPKG),
|
(f"{PROJECT_ROOT}/{PYPKG}/*.json", PYPKG),
|
||||||
(electrum + PYPKG + '/lnwire/*.csv', PYPKG + '/lnwire'),
|
(f"{PROJECT_ROOT}/{PYPKG}/lnwire/*.csv", f"{PYPKG}/lnwire"),
|
||||||
(electrum + PYPKG + '/wordlist/english.txt', PYPKG + '/wordlist'),
|
(f"{PROJECT_ROOT}/{PYPKG}/wordlist/english.txt", f"{PYPKG}/wordlist"),
|
||||||
(electrum + PYPKG + '/wordlist/slip39.txt', PYPKG + '/wordlist'),
|
(f"{PROJECT_ROOT}/{PYPKG}/wordlist/slip39.txt", f"{PYPKG}/wordlist"),
|
||||||
(electrum + PYPKG + '/locale', PYPKG + '/locale'),
|
(f"{PROJECT_ROOT}/{PYPKG}/locale", f"{PYPKG}/locale"),
|
||||||
(electrum + PYPKG + '/plugins', PYPKG + '/plugins'),
|
(f"{PROJECT_ROOT}/{PYPKG}/plugins", f"{PYPKG}/plugins"),
|
||||||
(electrum + PYPKG + '/gui/icons', PYPKG + '/gui/icons'),
|
(f"{PROJECT_ROOT}/{PYPKG}/gui/icons", f"{PYPKG}/gui/icons"),
|
||||||
]
|
]
|
||||||
datas += collect_data_files('electrum.plugins')
|
datas += collect_data_files(f"{PYPKG}.plugins")
|
||||||
datas += collect_data_files('trezorlib') # TODO is this needed? and same question for other hww libs
|
datas += collect_data_files('trezorlib') # TODO is this needed? and same question for other hww libs
|
||||||
datas += collect_data_files('safetlib')
|
datas += collect_data_files('safetlib')
|
||||||
datas += collect_data_files('btchip')
|
datas += collect_data_files('btchip')
|
||||||
@@ -40,22 +40,22 @@ datas += collect_data_files('keepkeylib')
|
|||||||
datas += collect_data_files('ckcc')
|
datas += collect_data_files('ckcc')
|
||||||
datas += collect_data_files('bitbox02')
|
datas += collect_data_files('bitbox02')
|
||||||
|
|
||||||
binaries = [(electrum + "electrum/*.dylib", ".")]
|
binaries = [(f"{PROJECT_ROOT}/{PYPKG}/*.dylib", ".")]
|
||||||
|
|
||||||
# Workaround for "Retro Look":
|
# Workaround for "Retro Look":
|
||||||
binaries += [b for b in collect_dynamic_libs('PyQt5') if 'macstyle' in b[0]]
|
binaries += [b for b in collect_dynamic_libs('PyQt5') if 'macstyle' in b[0]]
|
||||||
|
|
||||||
# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
|
# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
|
||||||
a = Analysis([electrum+ MAIN_SCRIPT,
|
a = Analysis([f"{PROJECT_ROOT}/{MAIN_SCRIPT}",
|
||||||
electrum+'electrum/gui/qt/main_window.py',
|
f"{PROJECT_ROOT}/{PYPKG}/gui/qt/main_window.py",
|
||||||
electrum+'electrum/gui/qt/qrreader/qtmultimedia/camera_dialog.py',
|
f"{PROJECT_ROOT}/{PYPKG}/gui/qt/qrreader/qtmultimedia/camera_dialog.py",
|
||||||
electrum+'electrum/gui/text.py',
|
f"{PROJECT_ROOT}/{PYPKG}/gui/text.py",
|
||||||
electrum+'electrum/util.py',
|
f"{PROJECT_ROOT}/{PYPKG}/util.py",
|
||||||
electrum+'electrum/wallet.py',
|
f"{PROJECT_ROOT}/{PYPKG}/wallet.py",
|
||||||
electrum+'electrum/simple_config.py',
|
f"{PROJECT_ROOT}/{PYPKG}/simple_config.py",
|
||||||
electrum+'electrum/bitcoin.py',
|
f"{PROJECT_ROOT}/{PYPKG}/bitcoin.py",
|
||||||
electrum+'electrum/dnssec.py',
|
f"{PROJECT_ROOT}/{PYPKG}/dnssec.py",
|
||||||
electrum+'electrum/commands.py',
|
f"{PROJECT_ROOT}/{PYPKG}/commands.py",
|
||||||
],
|
],
|
||||||
binaries=binaries,
|
binaries=binaries,
|
||||||
datas=datas,
|
datas=datas,
|
||||||
@@ -87,7 +87,7 @@ exe = EXE(
|
|||||||
debug=False,
|
debug=False,
|
||||||
strip=False,
|
strip=False,
|
||||||
upx=True,
|
upx=True,
|
||||||
icon=electrum+ICONS_FILE,
|
icon=ICONS_FILE,
|
||||||
console=False,
|
console=False,
|
||||||
target_arch='x86_64', # TODO investigate building 'universal2'
|
target_arch='x86_64', # TODO investigate building 'universal2'
|
||||||
)
|
)
|
||||||
@@ -97,9 +97,9 @@ app = BUNDLE(
|
|||||||
a.binaries,
|
a.binaries,
|
||||||
a.zipfiles,
|
a.zipfiles,
|
||||||
a.datas,
|
a.datas,
|
||||||
version = VERSION,
|
version=VERSION,
|
||||||
name=PACKAGE + '.app',
|
name=PACKAGE_NAME,
|
||||||
icon=electrum+ICONS_FILE,
|
icon=ICONS_FILE,
|
||||||
bundle_identifier=None,
|
bundle_identifier=None,
|
||||||
info_plist={
|
info_plist={
|
||||||
'NSHighResolutionCapable': 'True',
|
'NSHighResolutionCapable': 'True',
|
||||||
|
|||||||
Reference in New Issue
Block a user