Skip to content

Commit

Permalink
pyinstaller is driving me mad.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Robert M Ochshorn authored and Robert M Ochshorn committed Dec 1, 2015
1 parent 77d24a9 commit da5253a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
27 changes: 12 additions & 15 deletions gentle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
)
})
3 changes: 3 additions & 0 deletions gentle/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions make_dmg.sh
Original file line number Diff line number Diff line change
@@ -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/

0 comments on commit da5253a

Please sign in to comment.