From 1d26217bf7c7d92ed894994a59f2ff9aa4fb15f1 Mon Sep 17 00:00:00 2001
From: Holger Nahrstaedt <holger@nahrstaedt.de>
Date: Sat, 5 May 2018 07:47:00 +0200
Subject: [PATCH] Add building of pyinstaller to macos

---
 .travis.yml         |  3 +++
 appveyor.yml        |  1 +
 beempy-onedir.spec  | 10 +++++++++-
 beempy-onefile.spec |  8 ++++++++
 util/package-osx.sh | 27 +++++++++++++++++++++++++++
 5 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 util/package-osx.sh

diff --git a/.travis.yml b/.travis.yml
index 8ed0348a..1c4be61a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -57,11 +57,14 @@ before_install:
   - pip install --upgrade wheel
   # Set numpy version first, other packages link against it
   - pip install six nose coverage codecov tox-travis pytest pytest-cov coveralls codacy-coverage parameterized secp256k1 cryptography scrypt
+  - pip install pycryptodomex  pyyaml appdirs pylibscrypt
+  - pip install ecdsa requests future websocket-client pytz six Click events prettytable
 
 script:
  - tox
 
 after_success:
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bash util/package-osx.sh; fi
  - coveralls
   # - codecov 
   # - python-codacy-coverage -r coverage.xml
diff --git a/appveyor.yml b/appveyor.yml
index 628122d2..0fe357a2 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -85,6 +85,7 @@ after_test:
 
 - ps: | # generate sha256 hashes
     (get-filehash $env:BUILD -algorithm SHA256).Hash | out-file ("{0}.sha256" -f $env:BUILD) -encoding ascii
+    type ("{0}.sha256" -f $env:BUILD)
     
 #(get-filehash beempy.zip -algorithm SHA256).Hash | out-file "beempy.zip.sha256" -encoding ascii 
 
diff --git a/beempy-onedir.spec b/beempy-onedir.spec
index d88b23b6..a916dd5b 100644
--- a/beempy-onedir.spec
+++ b/beempy-onedir.spec
@@ -45,4 +45,12 @@ coll = COLLECT(
     name='beempy',
     strip=False,
     upx=False
-)
\ No newline at end of file
+)
+
+if platform.system() == 'Darwin':
+    info_plist = {'NSHighResolutionCapable': 'True', 'NSPrincipalClass': 'NSApplication'}
+    app = BUNDLE(exe,
+                 name='beempy.app',
+                 icon='beempy.ico',
+                 bundle_identifier=None
+                )
\ No newline at end of file
diff --git a/beempy-onefile.spec b/beempy-onefile.spec
index a05ef965..70a22efd 100644
--- a/beempy-onefile.spec
+++ b/beempy-onefile.spec
@@ -38,3 +38,11 @@ exe = EXE(pyz,
           console=True,
           icon='beempy.ico',
  )
+
+if platform.system() == 'Darwin':
+    info_plist = {'NSHighResolutionCapable': 'True', 'NSPrincipalClass': 'NSApplication'}
+    app = BUNDLE(exe,
+                 name='beempy.app',
+                 icon='beempy.ico',
+                 bundle_identifier=None
+                )
\ No newline at end of file
diff --git a/util/package-osx.sh b/util/package-osx.sh
new file mode 100644
index 00000000..8f0cad10
--- /dev/null
+++ b/util/package-osx.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+if [ -z "$CI_BUILD_TAG" ]
+then
+    python setup.py patch_version --platform=osx
+fi
+VERSION=$(python -c 'import beem; print(beem.__version__)')
+
+rm -rf dist build locale
+pip install 
+python setup.py clean
+python setup.py build_ext
+python setup.py build_locales
+pip install pyinstaller
+pyinstaller beempy-onedir.spec
+
+cd dist
+ditto -rsrc --arch x86_64 'beempy.app' 'beempy.tmp'
+rm -r 'beempy.app'
+mv 'beempy.tmp' 'beempy.app'
+hdiutil create -volname "beempy $VERSION" -srcfolder 'beempy.app' -ov -format UDBZ "beempy $VERSION.dmg"
+if [ -n "$UPLOAD_OSX" ]
+then
+    curl --upload-file "beempy $VERSION.dmg" https://transfer.sh/
+    # Required for a newline between the outputs
+    echo -e "\n"
+    md5 -r "beempy $VERSION.dmg"
+fi
-- 
GitLab