Skip to content

Commit

Permalink
[TASK] Update build script
Browse files Browse the repository at this point in the history
(needs some manual work)
[TASK] Add spec file to repo
  • Loading branch information
Sharrnah committed Jul 2, 2023
1 parent 1964c72 commit ee7fec8
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 18 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.idea/
__pycache__
/dist_files/ffmpeg/
/audioWhisper.spec
*.yaml
/build/
/dist/
95 changes: 95 additions & 0 deletions audioWhisper.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files
from PyInstaller.utils.hooks import collect_all
from PyInstaller.utils.hooks import copy_metadata
import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)

datas = []
binaries = []
hiddenimports = ['pytorch', 'torchaudio.lib.libtorchaudio', 'scipy.signal', 'transformers.models.nllb', 'sentencepiece']
datas += collect_data_files('torch')
datas += collect_data_files('whisper')
datas += collect_data_files('pykakasi')
datas += copy_metadata('torch')
datas += copy_metadata('tqdm')
datas += copy_metadata('regex')
datas += copy_metadata('requests')
datas += copy_metadata('packaging')
datas += copy_metadata('filelock')
datas += copy_metadata('numpy')
datas += copy_metadata('tokenizers')
datas += copy_metadata('rich')
datas += copy_metadata('sentencepiece')
datas += copy_metadata('transformers')
tmp_ret = collect_all('easyocr')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('winsdk')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('ctranslate2')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('torchaudio')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('scipy')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('lazy_loader')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('decorator')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('librosa')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('torchlibrosa')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('sentencepiece')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('transformers')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]


block_cipher = None


a = Analysis(
['audioWhisper.py'],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
[('u', None, 'OPTION')],
exclude_binaries=True,
name='audioWhisper',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['app-icon.ico'],
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='audioWhisper',
)
56 changes: 39 additions & 17 deletions build-standalone.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,42 @@ pip install -U pyinstaller
rem install plugin dependencies (also added in pyinstaller)
pip install winsdk

pyinstaller audioWhisper.py -y ^
--python-option=u ^
--hidden-import=pytorch --collect-data torch --copy-metadata torch ^
--hidden-import=torchaudio.lib.libtorchaudio ^
--copy-metadata tqdm ^
--copy-metadata regex ^
--copy-metadata requests ^
--copy-metadata packaging ^
--copy-metadata filelock ^
--copy-metadata numpy ^
--copy-metadata tokenizers ^
--collect-data whisper ^
--collect-data pykakasi ^
--collect-all easyocr ^
--collect-all winsdk ^
--collect-all ctranslate2 ^
-i app-icon.ico
rem pyinstaller audioWhisper.py -y ^
rem --python-option=u ^
rem --hidden-import=pytorch --collect-data torch --copy-metadata torch ^
rem --hidden-import=torchaudio.lib.libtorchaudio ^
rem --hidden-import=scipy.signal ^
rem --hidden-import=transformers.models.nllb ^
rem --hidden-import=sentencepiece ^
rem --copy-metadata tqdm ^
rem --copy-metadata regex ^
rem --copy-metadata requests ^
rem --copy-metadata packaging ^
rem --copy-metadata filelock ^
rem --copy-metadata numpy ^
rem --copy-metadata tokenizers ^
rem --copy-metadata rich ^
rem --copy-metadata sentencepiece ^
rem --copy-metadata transformers ^
rem --collect-data whisper ^
rem --collect-data pykakasi ^
rem --collect-all easyocr ^
rem --collect-all winsdk ^
rem --collect-all ctranslate2 ^
rem --collect-all torchaudio ^
rem --collect-all scipy ^
rem --collect-all lazy_loader ^
rem --collect-all decorator ^
rem --collect-all librosa ^
rem --collect-all torchlibrosa ^
rem --collect-all sentencepiece ^
rem --collect-all transformers ^
rem -i app-icon.ico

rem set pyrecursivelimit=import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)
rem (echo %pyrecursivelimit%) > temp.txt & type audioWhisper.spec >> temp.txt & move /y temp.txt audioWhisper.spec >nul

rem 1. In your program's .spec file add this line near the top::
rem import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)

pyinstaller audioWhisper.spec -y

0 comments on commit ee7fec8

Please sign in to comment.