From b9fa89ec19f867d6a91d8583293ce4d41d6da89c Mon Sep 17 00:00:00 2001 From: Johann Bauer Date: Tue, 30 Jan 2018 21:14:28 +0100 Subject: [PATCH 1/2] Update macOS build --- README.rst | 12 ++--------- contrib/build-osx/README.md | 17 ++++++++++++++++ contrib/build-osx/make_osx | 34 ++++++++++++++++++++++++++++++++ contrib/{ => build-osx}/osx.spec | 4 ++-- contrib/make_osx | 6 ------ 5 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 contrib/build-osx/README.md create mode 100755 contrib/build-osx/make_osx rename contrib/{ => build-osx}/osx.spec (94%) delete mode 100755 contrib/make_osx diff --git a/README.rst b/README.rst index 43d3257f6..9b1832354 100644 --- a/README.rst +++ b/README.rst @@ -93,20 +93,12 @@ This directory contains the python dependencies used by Electrum. Mac OS X / macOS -------- -:: - - # On MacPorts installs: - sudo python3 setup-release.py py2app - - # On Homebrew installs: - ARCHFLAGS="-arch i386 -arch x86_64" sudo python3 setup-release.py py2app --includes sip - - sudo hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-VERSION-macosx.dmg +See `contrib/build-osx/`. Windows ------- -See `contrib/build-wine/README` file. +See `contrib/build-wine/`. Android diff --git a/contrib/build-osx/README.md b/contrib/build-osx/README.md new file mode 100644 index 000000000..48a271d46 --- /dev/null +++ b/contrib/build-osx/README.md @@ -0,0 +1,17 @@ +Building Mac OS binaries +======================== + +This guide explains how to build Electrum binaries for macOS systems. +We build our binaries on El Capitan (10.11.6) as building it on High Sierra +makes the binaries incompatible with older versions. + + +## 1. Run the script + + + + ./make_osx + +## 2. Done + +Hopefully it will be that simple. \ No newline at end of file diff --git a/contrib/build-osx/make_osx b/contrib/build-osx/make_osx new file mode 100755 index 000000000..360b29968 --- /dev/null +++ b/contrib/build-osx/make_osx @@ -0,0 +1,34 @@ +#!/bin/bash +build_dir=$(dirname "$0") +test -n "$build_dir" -a -d "$build_dir" || exit +cd $build_dir/../.. + +export PYTHONHASHSEED=22 +VERSION=`git describe --tags` + +sw_vers +python3 --version +echo -n "Pyinstaller version " +pyinstaller --version + +rm -rf ./dist + + +rm -rf /tmp/electrum-build > /dev/null 2>&1 +mkdir /tmp/electrum-build + + +echo "Downloading icons and locale..." +for repo in icons locale; do + git clone https://github.com/spesmilo/electrum-$repo /tmp/electrum-build/electrum-$repo +done + +cp -R /tmp/electrum-build/electrum-locale/locale/ ./lib/locale/ +cp /tmp/electrum-build/electrum-icons/icons_rc.py ./gui/qt/ + +echo "Building Electrum..." +python3 setup.py install --user > /dev/null +python3 -m pip install pyqt5 --user + +pyinstaller --noconfirm --ascii --name $VERSION contrib/build-osx/osx.spec +hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-$VERSION.dmg diff --git a/contrib/osx.spec b/contrib/build-osx/osx.spec similarity index 94% rename from contrib/osx.spec rename to contrib/build-osx/osx.spec index 9dabf291c..bd3d8cf48 100644 --- a/contrib/osx.spec +++ b/contrib/build-osx/osx.spec @@ -12,8 +12,8 @@ for i, x in enumerate(sys.argv): else: raise BaseException('no version') -electrum = "../" -block_cipher=None +electrum = os.path.abspath("../../") +block_cipher = None # see https://github.com/pyinstaller/pyinstaller/issues/2005 hiddenimports = [] diff --git a/contrib/make_osx b/contrib/make_osx deleted file mode 100755 index f354e331a..000000000 --- a/contrib/make_osx +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -rm -rf dist -export PYTHONHASHSEED=22 -VERSION=`git describe --tags` -pyinstaller --noconfirm --ascii --name $VERSION contrib/osx.spec -hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-$VERSION.dmg From 0f40c147924d466eb1bc2caf86680e6b22b06dfc Mon Sep 17 00:00:00 2001 From: Johann Bauer Date: Wed, 31 Jan 2018 13:16:27 +0100 Subject: [PATCH 2/2] Use requirements files --- contrib/build-osx/README.md | 4 +-- contrib/build-osx/make_osx | 57 +++++++++++++++++++++++++++++++------ contrib/build-osx/osx.spec | 2 +- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/contrib/build-osx/README.md b/contrib/build-osx/README.md index 48a271d46..af43e05ce 100644 --- a/contrib/build-osx/README.md +++ b/contrib/build-osx/README.md @@ -5,6 +5,8 @@ This guide explains how to build Electrum binaries for macOS systems. We build our binaries on El Capitan (10.11.6) as building it on High Sierra makes the binaries incompatible with older versions. +This assumes that the Xcode command line tools (and thus git) are already installed. + ## 1. Run the script @@ -13,5 +15,3 @@ makes the binaries incompatible with older versions. ./make_osx ## 2. Done - -Hopefully it will be that simple. \ No newline at end of file diff --git a/contrib/build-osx/make_osx b/contrib/build-osx/make_osx index 360b29968..d8af8c9d6 100755 --- a/contrib/build-osx/make_osx +++ b/contrib/build-osx/make_osx @@ -1,14 +1,45 @@ #!/bin/bash +RED='\033[0;31m' +BLUE='\033[0,34m' +NC='\033[0m' # No Color +function info { + printf "\r💬 ${BLUE}INFO:${NC} ${1}\n" +} +function fail { + printf "\r🗯 ${RED}ERROR:${NC} ${1}\n" + exit 1 +} + build_dir=$(dirname "$0") test -n "$build_dir" -a -d "$build_dir" || exit cd $build_dir/../.. export PYTHONHASHSEED=22 VERSION=`git describe --tags` +PYTHON_VERSION=3.6.4 + + +info "Installing Python $PYTHON_VERSION" +export PATH="~/.pyenv/bin:~/.pyenv/shims:$PATH:~/Library/Python/3.6/bin" +if [ -d "~/.pyenv" ]; then + pyenv update +else + curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash > /dev/null 2>&1 +fi +PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -s $PYTHON_VERSION && \ +pyenv global $PYTHON_VERSION || \ +fail "Unable to use Python $PYTHON_VERSION" + + +if ! which pyinstaller > /dev/null; then + info "Installing pyinstaller" + python3 -m pip install pyinstaller -I --user || fail "Could not install pyinstaller" +fi +info "Using these versions for building Electrum:" sw_vers python3 --version -echo -n "Pyinstaller version " +echo -n "Pyinstaller " pyinstaller --version rm -rf ./dist @@ -17,8 +48,7 @@ rm -rf ./dist rm -rf /tmp/electrum-build > /dev/null 2>&1 mkdir /tmp/electrum-build - -echo "Downloading icons and locale..." +info "Downloading icons and locale..." for repo in icons locale; do git clone https://github.com/spesmilo/electrum-$repo /tmp/electrum-build/electrum-$repo done @@ -26,9 +56,20 @@ done cp -R /tmp/electrum-build/electrum-locale/locale/ ./lib/locale/ cp /tmp/electrum-build/electrum-icons/icons_rc.py ./gui/qt/ -echo "Building Electrum..." -python3 setup.py install --user > /dev/null -python3 -m pip install pyqt5 --user +info "Installing requirements..." +python3 -m pip install -Ir ./contrib/deterministic-build/requirements.txt --user && \ +python3 -m pip install pyqt5 --user || \ +fail "Could not install requirements" + +info "Installing hardware wallet requirements..." +python3 -m pip install -Ir ./contrib/deterministic-build/requirements-hw.txt --user || \ +fail "Could not install hardware wallet requirements" + +info "Building Electrum..." +python3 setup.py install --user > /dev/null || fail "Could not build Electrum" + +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 -hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-$VERSION.dmg +info "Creating .DMG" +hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-$VERSION.dmg || fail "Could not create .DMG" diff --git a/contrib/build-osx/osx.spec b/contrib/build-osx/osx.spec index bd3d8cf48..cfce7172f 100644 --- a/contrib/build-osx/osx.spec +++ b/contrib/build-osx/osx.spec @@ -12,7 +12,7 @@ for i, x in enumerate(sys.argv): else: raise BaseException('no version') -electrum = os.path.abspath("../../") +electrum = os.path.abspath(".") + "/" block_cipher = None # see https://github.com/pyinstaller/pyinstaller/issues/2005