fix: assets missing in PyInstaller build

This commit is contained in:
Chidi Williams 2024-01-10 22:42:45 +00:00
parent a0ee06109b
commit 1448f70c2c
3 changed files with 22 additions and 10 deletions

View file

@ -21,22 +21,32 @@ datas += copy_metadata("tokenizers")
datas += collect_data_files("transformers", include_py_files=True)
datas += collect_data_files("whisper")
datas += [
("buzz/whisper.dll" if platform.system() == "Windows" else "buzz/libwhisper.*", ".")
]
datas += [("assets/*", "assets")]
datas += [("buzz/assets/*", "assets")]
datas += [
(file[1], os.path.dirname(file[1]))
for file in Tree("./locale", prefix="locale", excludes=["*.po"])
]
datas += [(shutil.which("ffmpeg"), ".")]
block_cipher = None
DEBUG = os.environ.get("PYINSTALLER_DEBUG", "").lower() in ["1", "true"]
if DEBUG:
options = [("v", None, "OPTION")]
else:
options = []
binaries = [
(
"buzz/whisper.dll" if platform.system() == "Windows" else "buzz/libwhisper.*",
".",
),
(shutil.which("ffmpeg"), "."),
]
a = Analysis(
["main.py"],
pathex=[],
binaries=[],
binaries=binaries,
datas=datas,
hiddenimports=[],
hookspath=[],
@ -53,15 +63,15 @@ pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
options,
icon="./assets/buzz.ico",
exclude_binaries=True,
name="Buzz",
debug=True,
debug=DEBUG,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
console=DEBUG,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,

View file

@ -4,5 +4,5 @@ import sys
def get_asset_path(path: str):
if getattr(sys, "frozen", False):
return os.path.join(os.path.dirname(sys.executable), "buzz", path)
return os.path.join(os.path.dirname(sys.executable), path)
return os.path.join(os.path.dirname(__file__), path)

View file

@ -47,6 +47,8 @@ def main():
format=log_format,
)
logging.debug("app_dir: %s", app_dir)
if getattr(sys, "frozen", False) is False:
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(logging.DEBUG)