From da5253a08d28167f0caad027ad73d10b11737792 Mon Sep 17 00:00:00 2001 From: Robert M Ochshorn Date: Mon, 30 Nov 2015 20:52:31 -0800 Subject: [PATCH] pyinstaller is driving me mad. there was one bug that was genuinely ours: by moving the extensions into ext/, but keeping them (in gentle.spec) in Resources/, shelling out to them failed. fine. i've fixed that by moving the entire ext/ folder to Resources/. as a hack, ffmpeg is in there too, so the get_binary function adds ext/ if we're frozen. i have no idea why pyinstaller all of a sudden (using the python.org python) decided to put the entire gentle/ directory into the bundle. there's an egregious hack in make_dmg.sh to work around that. --- gentle.spec | 27 ++++++++++++--------------- gentle/paths.py | 3 +++ make_dmg.sh | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 make_dmg.sh diff --git a/gentle.spec b/gentle.spec index bda1515a..552e6bd0 100644 --- a/gentle.spec +++ b/gentle.spec @@ -4,44 +4,41 @@ block_cipher = None import os data_files = [] -for dirpath in ['www', 'data', 'PROTO_LANGDIR']: +for dirpath in ['www', 'data', 'PROTO_LANGDIR', 'ext']: data_files.append((dirpath, dirpath)) -for exepath in ['ffmpeg', 'ext/standard_kaldi', 'ext/mkgraph']: - data_files.append((exepath, '')) a = Analysis(['gentle.py'], pathex=[os.path.abspath(os.curdir)], binaries=None, datas=data_files, hiddenimports=[], - hookspath=None, - runtime_hooks=None, - excludes=None, - win_no_prefer_redirects=None, - win_private_assemblies=None, + 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, exclude_binaries=True, - name='gentle', + name='gentler', debug=False, - strip=None, - upx=False, + strip=False, + upx=True, console=False ) coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, - strip=None, + strip=False, upx=True, - name='gentle') + name='gentler') app = BUNDLE(coll, name='gentle.app', icon=None, bundle_identifier=None, info_plist={ 'NSHighResolutionCapable': 'True' - }, -) + }) diff --git a/gentle/paths.py b/gentle/paths.py index 2fe37e71..af696a05 100644 --- a/gentle/paths.py +++ b/gentle/paths.py @@ -7,6 +7,9 @@ def get_binary(name): binpath = name if hasattr(sys, "frozen"): + # HACK + if name == 'ffmpeg': + name = 'ext/ffmpeg' binpath = os.path.abspath(os.path.join(sys._MEIPASS, '..', 'Resources', name)) elif os.path.exists(name): binpath = "./%s" % (name) diff --git a/make_dmg.sh b/make_dmg.sh new file mode 100644 index 00000000..c6a42cf8 --- /dev/null +++ b/make_dmg.sh @@ -0,0 +1,17 @@ +pyinstaller gentle.spec + +# For unknown reasons, pyinstaller suddenly started dumping this +# entire root directory into the folder (ie. once I changed the system +# python from homebrew to python.org). This makes zero sense. But in +# lieu of tracking down the bug, let's just go in and delete some of +# the nastier, offending files. +cd dist/gentle.app/Contents/Resources +rm -rf COPYING Dockerfile *.sh examples *.spec include lib tests *.pyc gentle *.py *.bkp webdata \ + .git* .travis.yml .DS_Store \ + ext/kaldi ext/*.dSYM ext/Makefile ext/*.cc +cd ../MacOS +rm COPYING Dockerfile *.sh examples *.spec include lib tests *.pyc gentle *.py *.bkp webdata \ + .git* .travis.yml .DS_Store +cd ../../../../ + +hdiutil create dist/gentle.dmg -volname "Gentle" -srcfolder dist/gentle.app/