Parameterise the OSX builder

This commit is contained in:
Neil Booth 2018-02-13 18:01:11 +08:00 committed by Johann Bauer
parent e0130cafcf
commit cc19de9db3
2 changed files with 34 additions and 24 deletions

View File

@ -16,7 +16,12 @@ cd $build_dir/../..
export PYTHONHASHSEED=22 export PYTHONHASHSEED=22
VERSION=`git describe --tags` VERSION=`git describe --tags`
# Paramterize
PYTHON_VERSION=3.6.4 PYTHON_VERSION=3.6.4
BUILDDIR=/tmp/electrum-build
PACKAGE=Electrum
GIT_REPO=https://github.com/spesmilo/electrum
info "Installing Python $PYTHON_VERSION" info "Installing Python $PYTHON_VERSION"
@ -34,7 +39,7 @@ fail "Unable to use Python $PYTHON_VERSION"
info "Installing pyinstaller" info "Installing pyinstaller"
python3 -m pip install pyinstaller -I --user || fail "Could not install pyinstaller" python3 -m pip install pyinstaller -I --user || fail "Could not install pyinstaller"
info "Using these versions for building Electrum:" info "Using these versions for building $PACKAGE:"
sw_vers sw_vers
python3 --version python3 --version
echo -n "Pyinstaller " echo -n "Pyinstaller "
@ -43,16 +48,16 @@ pyinstaller --version
rm -rf ./dist rm -rf ./dist
rm -rf /tmp/electrum-build > /dev/null 2>&1 rm -rf $BUILDDIR > /dev/null 2>&1
mkdir /tmp/electrum-build mkdir $BUILDDIR
info "Downloading icons and locale..." info "Downloading icons and locale..."
for repo in icons locale; do for repo in icons locale; do
git clone https://github.com/spesmilo/electrum-$repo /tmp/electrum-build/electrum-$repo git clone $GIT_REPO-$repo $BUILDDIR/electrum-$repo
done done
cp -R /tmp/electrum-build/electrum-locale/locale/ ./lib/locale/ cp -R $BUILDDIR/electrum-locale/locale/ ./lib/locale/
cp /tmp/electrum-build/electrum-icons/icons_rc.py ./gui/qt/ cp $BUILDDIR/electrum-icons/icons_rc.py ./gui/qt/
info "Installing requirements..." info "Installing requirements..."
python3 -m pip install -Ir ./contrib/deterministic-build/requirements.txt --user && \ python3 -m pip install -Ir ./contrib/deterministic-build/requirements.txt --user && \
@ -63,11 +68,11 @@ info "Installing hardware wallet requirements..."
python3 -m pip install -Ir ./contrib/deterministic-build/requirements-hw.txt --user || \ python3 -m pip install -Ir ./contrib/deterministic-build/requirements-hw.txt --user || \
fail "Could not install hardware wallet requirements" fail "Could not install hardware wallet requirements"
info "Building Electrum..." info "Building $PACKAGE..."
python3 setup.py install --user > /dev/null || fail "Could not build Electrum" python3 setup.py install --user > /dev/null || fail "Could not build $PACKAGE"
info "Building binary" info "Building binary"
pyinstaller --noconfirm --ascii --name $VERSION contrib/build-osx/osx.spec || fail "Could not build binary" pyinstaller --noconfirm --ascii --name $VERSION contrib/build-osx/osx.spec || fail "Could not build binary"
info "Creating .DMG" info "Creating .DMG"
hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-$VERSION.dmg || fail "Could not create .DMG" hdiutil create -fs HFS+ -volname $PACKAGE -srcfolder dist/$PACKAGE.app dist/electrum-$VERSION.dmg || fail "Could not create .DMG"

View File

@ -5,6 +5,11 @@ from PyInstaller.utils.hooks import collect_data_files, collect_submodules
import sys import sys
import os import os
PACKAGE='Electrum'
PYPKG='electrum'
MAIN_SCRIPT='electrum'
ICONS_FILE='electrum.icns'
for i, x in enumerate(sys.argv): for i, x in enumerate(sys.argv):
if x == '--name': if x == '--name':
VERSION = sys.argv[i+1] VERSION = sys.argv[i+1]
@ -22,21 +27,21 @@ hiddenimports += collect_submodules('btchip')
hiddenimports += collect_submodules('keepkeylib') hiddenimports += collect_submodules('keepkeylib')
datas = [ datas = [
(electrum+'lib/currencies.json', 'electrum'), (electrum+'lib/currencies.json', PYPKG),
(electrum+'lib/servers.json', 'electrum'), (electrum+'lib/servers.json', PYPKG),
(electrum+'lib/checkpoints.json', 'electrum'), (electrum+'lib/checkpoints.json', PYPKG),
(electrum+'lib/servers_testnet.json', 'electrum'), (electrum+'lib/servers_testnet.json', PYPKG),
(electrum+'lib/checkpoints_testnet.json', 'electrum'), (electrum+'lib/checkpoints_testnet.json', PYPKG),
(electrum+'lib/wordlist/english.txt', 'electrum/wordlist'), (electrum+'lib/wordlist/english.txt', PYPKG + '/wordlist'),
(electrum+'lib/locale', 'electrum/locale'), (electrum+'lib/locale', PYPKG + '/locale'),
(electrum+'plugins', 'electrum_plugins'), (electrum+'plugins', PYPKG + '_plugins'),
] ]
datas += collect_data_files('trezorlib') datas += collect_data_files('trezorlib')
datas += collect_data_files('btchip') datas += collect_data_files('btchip')
datas += collect_data_files('keepkeylib') datas += collect_data_files('keepkeylib')
# 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+'electrum', a = Analysis([electrum+MAIN_SCRIPT,
electrum+'gui/qt/main_window.py', electrum+'gui/qt/main_window.py',
electrum+'gui/text.py', electrum+'gui/text.py',
electrum+'lib/util.py', electrum+'lib/util.py',
@ -68,17 +73,17 @@ exe = EXE(pyz,
a.scripts, a.scripts,
a.binaries, a.binaries,
a.datas, a.datas,
name='Electrum', name=PACKAGE,
debug=False, debug=False,
strip=False, strip=False,
upx=True, upx=True,
icon=electrum+'electrum.icns', icon=electrum+ICONS_FILE,
console=False) console=False)
app = BUNDLE(exe, app = BUNDLE(exe,
version = VERSION, version = VERSION,
name='Electrum.app', name=PACKAGE + '.app',
icon=electrum+'electrum.icns', icon=electrum+ICONS_FILE,
bundle_identifier=None, bundle_identifier=None,
info_plist = { info_plist = {
'NSHighResolutionCapable':'True' 'NSHighResolutionCapable':'True'