From ee7fec87353036f85952ac4738e82fa902445e24 Mon Sep 17 00:00:00 2001 From: Sharrnah <55756126+Sharrnah@users.noreply.github.com> Date: Sun, 2 Jul 2023 21:22:56 +0200 Subject: [PATCH] [TASK] Update build script (needs some manual work) [TASK] Add spec file to repo --- .gitignore | 1 - audioWhisper.spec | 95 ++++++++++++++++++++++++++++++++++++++++++++ build-standalone.bat | 56 ++++++++++++++++++-------- 3 files changed, 134 insertions(+), 18 deletions(-) create mode 100644 audioWhisper.spec diff --git a/.gitignore b/.gitignore index 9f9a203..f4e4212 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .idea/ __pycache__ /dist_files/ffmpeg/ -/audioWhisper.spec *.yaml /build/ /dist/ diff --git a/audioWhisper.spec b/audioWhisper.spec new file mode 100644 index 0000000..7f6915f --- /dev/null +++ b/audioWhisper.spec @@ -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', +) diff --git a/build-standalone.bat b/build-standalone.bat index 8f4e43a..48a5fde 100644 --- a/build-standalone.bat +++ b/build-standalone.bat @@ -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