diff --git a/build.sh b/build.sh index 30f927b..5feae3a 100755 --- a/build.sh +++ b/build.sh @@ -5,10 +5,22 @@ set -eE ./setup.sh source .venv/bin/activate pip install pyinstaller -pyinstaller -y precise.engine.spec -out_name="precise-engine_$(precise-engine --version 2>&1)_$(uname -m).tar.gz" +rm -rf dist/ + +for script in listen train calc_threshold; do + tmp_name=$(mktemp).spec + cat "precise.template.spec" | sed -e 's/%%SCRIPT%%/'"$script"'/gm' > "$tmp_name" + pyinstaller -y "$tmp_name" +done + +items=dist/* +for i in $items; do + mkdir -p dist/precise + cp -R $i/* dist/precise +done + +out_name="precise_$(precise-engine --version 2>&1)_$(uname -m).tar.gz" cd dist -tar czvf "$out_name" "precise-engine" +tar czvf "$out_name" "precise" echo "Wrote to dist/$out_name" - diff --git a/precise.engine.spec b/precise.engine.spec deleted file mode 100644 index d73a557..0000000 --- a/precise.engine.spec +++ /dev/null @@ -1,34 +0,0 @@ -# -*- mode: python -*- -block_cipher = None - -a = Analysis(['precise/scripts/engine.py'], - pathex=['.'], - binaries=[], - datas=[], - hiddenimports=['prettyparse', 'speechpy'], - hookspath=[], - runtime_hooks=[], - excludes=['PySide', 'PyQt4', 'PyQt5', 'matplotlib'], - 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='precise-engine', - debug=False, - strip=True, - upx=True, - console=True,) - -coll = COLLECT(exe, - a.binaries, - a.zipfiles, - a.datas, - strip=True, - upx=True, - name='precise-engine') diff --git a/precise.template.spec b/precise.template.spec new file mode 100644 index 0000000..3214804 --- /dev/null +++ b/precise.template.spec @@ -0,0 +1,53 @@ +# -*- mode: python -*- +block_cipher = None + +from glob import iglob +from os.path import basename, dirname, abspath + +script_name = '%%SCRIPT%%' +strip = False +site_packages = '.venv/lib/python3.6/site-packages/' +print('PATH:', abspath('precise/scripts/{}.py'.format(script_name))) + +a = Analysis( + [abspath('precise/scripts/{}.py'.format(script_name))], + pathex=['.'], + binaries=[ + (abspath(i), dirname(i.replace(site_packages, ''))) + for i in iglob(site_packages + "tensorflow/**/*.so", recursive=True) + ], + datas=[], + hiddenimports=['prettyparse', 'speechpy'], + hookspath=[], + runtime_hooks=[], + excludes=['PySide', 'PyQt4', 'PyQt5', 'matplotlib'], + 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='precise-{}'.format(script_name.replace('_', '-')), + debug=False, + strip=strip, + upx=True, + console=True +) + +coll = COLLECT( + exe, + a.binaries, + a.zipfiles, + a.datas, + strip=strip, + upx=True, + name='precise-{}'.format(script_name.replace('_', '-')) +)