Permalink
Browse files

[#408] Small reduction in bloat on Mac OS X

1 parent 30df8da commit 01907589af7a74061f4c071b11c207c340fec727 @quicklizard99 quicklizard99 committed Dec 15, 2016
Showing with 31 additions and 44 deletions.
  1. +0 −1 .gitignore
  2. +21 −4 build.sh
  3. +7 −2 inselect.spec
  4. +3 −1 read_barcodes.spec
  5. +0 −36 segment.spec
View
@@ -11,7 +11,6 @@ MANIFEST
*spec
!inselect.spec
!read_barcodes.spec
-!segment.spec
*tar.gz
*dmg
.directory
View
@@ -38,15 +38,32 @@ echo Wheel build
mv dist/inselect-*.whl .
if [[ "$OSTYPE" == "darwin"* ]]; then
+ # Modules to be excluded - .spec files read this env var
+ # See https://github.com/pyinstaller/pyinstaller/wiki/Recipe-remove-tkinter-tcl
+ # for details of excluding all of the tcl, tk, tkinter shat
+ export EXCLUDE_MODULES="2to3 elementtree FixTk PIL._imagingtk ssl tcl tk _tkinter tkinter Tkinter"
+
# Scripts that have additional requirements in their own spec files
- for script in inselect read_barcodes segment; do
+ for script in inselect read_barcodes; do
pyinstaller --clean $script.spec
done
- # Scripts for which the .spec file can be generated
- for script in export_metadata ingest save_crops; do
+ # Format excludes for pyinstaller command line
+ export EXCLUDE_MODULES=`python -c "print(' '.join('--exclude-module {0}'.format(e) for e in '$EXCLUDE_MODULES'.split(' ')))"`
+
+ # export_metadata uses neither cv2 nor numpy
+ pyinstaller --onefile --exclude-module cv2 --exclude-module numpy \
+ $EXCLUDE_MODULES inselect/scripts/export_metadata.py
+
+ pyinstaller --onefile $EXCLUDE_MODULES \
+ --hidden-import sklearn.neighbors.typedefs \
+ --hidden-import sklearn.neighbors.dist_metrics \
+ inselect/scripts/segment.py
+
+ # Other scripts
+ for script in ingest save_crops; do
rm -rf $script.spec
- pyinstaller --onefile --hidden-import numpy inselect/scripts/$script.py
+ pyinstaller --onefile $EXCLUDE_MODULES inselect/scripts/$script.py
done
# Add a few items to the PropertyList file generated by PyInstaller
View
@@ -1,4 +1,5 @@
# -*- mode: python -*-
+import os
import sys
from pathlib import Path
@@ -8,7 +9,12 @@ from pyzbar import pyzbar
block_cipher = None
+# See https://github.com/pyinstaller/pyinstaller/wiki/Recipe-remove-tkinter-tcl
+# for details of excluding all of the tcl, tk, tkinter shat
+sys.modules['FixTk'] = None
+
+print(os.getenv('EXCLUDE_MODULES', []).split(' '))
a = Analysis(
['inselect/scripts/inselect.py'],
pathex=[str(Path('.').absolute())],
@@ -19,7 +25,7 @@ a = Analysis(
hiddenimports=['sklearn.neighbors.typedefs'],
hookspath=[],
runtime_hooks=[],
- excludes=[],
+ excludes=os.getenv('EXCLUDE_MODULES', []).split(' '),
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher
@@ -32,7 +38,6 @@ a.binaries += TOC([
for dep in pylibdmtx.EXTERNAL_DEPENDENCIES + pyzbar.EXTERNAL_DEPENDENCIES
])
-
ICON = 'icons/inselect.icns'
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
View
@@ -1,4 +1,6 @@
# -*- mode: python -*-
+import os
+
from pathlib import Path
from pylibdmtx import pylibdmtx
@@ -15,7 +17,7 @@ a = Analysis(
hiddenimports=['numpy'],
hookspath=[],
runtime_hooks=[],
- excludes=[],
+ excludes=os.getenv('EXCLUDE_MODULES', []).split(' '),
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher
View
@@ -1,36 +0,0 @@
-# -*- mode: python -*-
-from pathlib import Path
-
-block_cipher = None
-
-
-a = Analysis(
- ['inselect/scripts/segment.py'],
- pathex=[str(Path('.').absolute())],
- binaries=[],
- datas=[],
- hiddenimports=[
- 'numpy', 'sklearn.neighbors.typedefs', 'sklearn.neighbors.dist_metrics'
- ],
- hookspath=[],
- runtime_hooks=[],
- excludes=[],
- win_no_prefer_redirects=False,
- win_private_assemblies=False,
- cipher=block_cipher
-)
-
-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 0190758

Please sign in to comment.