commit b9d8b2a5719546452b4f261a4944142ee0d07b13
parent 3e72e7a3f07fd0436b74299fb70c9669fa04c70d
Author: ThomasV <thomasv@electrum.org>
Date: Tue, 28 Nov 2017 18:20:14 +0100
windows: build portable version without patching the source
Diffstat:
4 files changed, 49 insertions(+), 55 deletions(-)
diff --git a/contrib/build-wine/build-electrum-git.sh b/contrib/build-wine/build-electrum-git.sh
@@ -10,6 +10,7 @@ fi
# These settings probably don't need any change
export WINEPREFIX=/opt/wine64
export PYTHONDONTWRITEBYTECODE=1
+export PYTHONHASHSEED=22
PYHOME=c:/python$PYTHON_VERSION
PYTHON="wine $PYHOME/python.exe -OO -B"
@@ -64,7 +65,7 @@ cd ..
rm -rf dist/
# build standalone version
-wine "C:/python$PYTHON_VERSION/scripts/pyinstaller.exe" --noconfirm --ascii --name $NAME_ROOT-$VERSION.exe -w deterministic.spec
+wine "C:/python$PYTHON_VERSION/scripts/pyinstaller.exe" --noconfirm --ascii --name $NAME_ROOT-$VERSION -w deterministic.spec
# build NSIS installer
# $VERSION could be passed to the electrum.nsi script, but this would require some rewriting in the script iself.
@@ -74,11 +75,4 @@ cd dist
mv electrum-setup.exe $NAME_ROOT-$VERSION-setup.exe
cd ..
-# build portable version
-cp portable.patch $WINEPREFIX/drive_c/electrum
-pushd $WINEPREFIX/drive_c/electrum
-patch < portable.patch
-popd
-wine "C:/python$PYTHON_VERSION/scripts/pyinstaller.exe" --noconfirm --ascii --name $NAME_ROOT-$VERSION-portable.exe -w deterministic.spec
-
echo "Done."
diff --git a/contrib/build-wine/deterministic.spec b/contrib/build-wine/deterministic.spec
@@ -26,7 +26,6 @@ datas = [
(home+'lib/wordlist/english.txt', 'electrum/wordlist'),
(home+'lib/locale', 'electrum/locale'),
(home+'plugins', 'electrum_plugins'),
- #(home+'packages/requests/cacert.pem', 'requests/cacert.pem')
]
datas += collect_data_files('trezorlib')
datas += collect_data_files('btchip')
@@ -70,44 +69,54 @@ pyz = PYZ(a.pure)
#####
# "standalone" exe with all dependencies packed into it
-# (or "portable", depending on cmdline_name)
exe_standalone = EXE(
- pyz,
- a.scripts,
- a.binaries,
- a.datas,
- name=os.path.join('build\\pyi.win32\\electrum', cmdline_name),
- debug=False,
- strip=None,
- upx=False,
- icon=home+'icons/electrum.ico',
- console=False)
- # The 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
+ pyz,
+ a.scripts,
+ a.binaries,
+ a.datas,
+ name=os.path.join('build\\pyi.win32\\electrum', cmdline_name + ".exe"),
+ debug=False,
+ strip=None,
+ upx=False,
+ icon=home+'icons/electrum.ico',
+ 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 + "-portable.exe"),
+ debug=False,
+ strip=None,
+ upx=False,
+ icon=home+'icons/electrum.ico',
+ console=False)
#####
# exe and separate files that NSIS uses to build installer "setup" exe
-# FIXME: this is redundantly done again, when building the "portable" exe
exe_dependent = EXE(
- pyz,
- a.scripts,
- exclude_binaries=True,
- name=os.path.join('build\\pyi.win32\\electrum', cmdline_name),
- debug=False,
- strip=None,
- upx=False,
- icon=home+'icons/electrum.ico',
- console=False)
+ pyz,
+ a.scripts,
+ exclude_binaries=True,
+ name=os.path.join('build\\pyi.win32\\electrum', cmdline_name),
+ debug=False,
+ strip=None,
+ upx=False,
+ icon=home+'icons/electrum.ico',
+ console=False)
coll = COLLECT(
- exe_dependent,
- a.binaries,
- a.zipfiles,
- a.datas,
- strip=None,
- upx=True,
- debug=False,
- icon=home+'icons/electrum.ico',
- console=False,
- name=os.path.join('dist', 'electrum'))
+ exe_dependent,
+ a.binaries,
+ a.zipfiles,
+ a.datas,
+ strip=None,
+ upx=True,
+ debug=False,
+ icon=home+'icons/electrum.ico',
+ console=False,
+ name=os.path.join('dist', 'electrum'))
diff --git a/contrib/build-wine/portable.patch b/contrib/build-wine/portable.patch
@@ -1,13 +0,0 @@
-diff --git a/electrum b/electrum
-index 8c972c6..46903b7 100755
---- a/electrum
-+++ b/electrum
-@@ -454,6 +454,8 @@ if __name__ == '__main__':
- if config_options.get('server'):
- config_options['auto_connect'] = False
-
-+ config_options['portable'] = True
-+
- if config_options.get('portable'):
- config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')
-
diff --git a/electrum b/electrum
@@ -316,7 +316,7 @@ if __name__ == '__main__':
elif arg == '?':
sys.argv[i] = input("Enter argument:")
elif arg == ':':
- sys.argv[i] = prompt_password('Enter argument (will noot echo):', False)
+ sys.argv[i] = prompt_password('Enter argument (will not echo):', False)
# parse command line
parser = get_parser()
@@ -338,6 +338,10 @@ if __name__ == '__main__':
config_options['cwd'] = os.getcwd()
+ # fixme: this can probably be achieved with a runtime hook (pyinstaller)
+ if is_bundle and os.path.exists(os.path.join(sys._MEIPASS, 'is_portable')):
+ config_options.get('portable') = True
+
if config_options.get('portable'):
config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')