From 95a9c48af938738007d519286041578ca3ec4d3f Mon Sep 17 00:00:00 2001 From: Lawrence Hudson Date: Tue, 14 Jun 2016 11:53:56 +0100 Subject: [PATCH] Fix freeze of segment on OS X --- .gitignore | 1 + build.sh | 7 +++---- inselect.spec | 4 ++++ segment.spec | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 segment.spec diff --git a/.gitignore b/.gitignore index c90f884..456db90 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ cover MANIFEST *spec !inselect.spec +!segment.spec *tar.gz *dmg .directory diff --git a/build.sh b/build.sh index 95a549f..e0c72ed 100755 --- a/build.sh +++ b/build.sh @@ -43,10 +43,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then rm -rf $script.spec pyinstaller --onefile --hidden-import numpy inselect/scripts/$script.py done - # segment has an additional hidden import - rm -rf segment.spec - pyinstaller --onefile --hidden-import numpy \ - --hidden-import sklearn.neighbors.typedefs inselect/scripts/segment.py + + # segment has additional requirements so have its own spec file + pyinstaller --clean segment.spec # Add a few items to the PropertyList file generated by PyInstaller python -m bin.plist dist/inselect.app/Contents/Info.plist diff --git a/inselect.spec b/inselect.spec index 29f6680..5fdaf84 100644 --- a/inselect.spec +++ b/inselect.spec @@ -25,6 +25,10 @@ a = Analysis(['inselect.py'], # of manipulating Analysis.binaries. MISSING_DYLIBS = ( + 'libiomp5.dylib', + 'libmkl_intel_lp64.dylib', + 'libmkl_intel_thread.dylib', + 'libmkl_core.dylib', 'libQtCore.4.dylib', 'libQtGui.4.dylib', 'libpng16.16.dylib', diff --git a/segment.spec b/segment.spec new file mode 100644 index 0000000..1aef4b0 --- /dev/null +++ b/segment.spec @@ -0,0 +1,51 @@ +# -*- mode: python -*- +import sys + +from pathlib import Path + +block_cipher = None + + +a = Analysis(['inselect/scripts/segment.py'], + pathex=['/Users/lawrence/projects/inselect'], + binaries=None, + datas=None, + hiddenimports=['numpy', 'sklearn.neighbors.typedefs'], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher) + +# PyInstaller does not detect some dylibs, I think in some cases because they +# are symlinked. +# See Stack Overflow post http://stackoverflow.com/a/17595149 for example +# of manipulating Analysis.binaries. +MISSING_DYLIBS = ( + 'libiomp5.dylib', + 'libmkl_intel_lp64.dylib', + 'libmkl_intel_thread.dylib', + 'libmkl_core.dylib', +) + +# The lib directory associated with this environment +LIB = Path(sys.argv[0]).parent.parent.joinpath('lib') + +# Find the source for each library and add it to the list of binaries +a.binaries += TOC([ + (lib, str(LIB.joinpath(lib).resolve()), 'BINARY') for lib in MISSING_DYLIBS +]) + +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + name='segment', + debug=False, + strip=False, + upx=True, + console=True )