Skip to content

Commit

Permalink
Fix freeze of segment on OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklizard99 committed Jun 14, 2016
1 parent 6766cf0 commit 95a9c48
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cover
MANIFEST
*spec
!inselect.spec
!segment.spec
*tar.gz
*dmg
.directory
Expand Down
7 changes: 3 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions inselect.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
51 changes: 51 additions & 0 deletions segment.spec
Original file line number Diff line number Diff line change
@@ -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 )

0 comments on commit 95a9c48

Please sign in to comment.