From 5cda68a598d36a8b73b04593c7a72ab7d30cf42e Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Wed, 10 Jan 2024 09:27:33 +0000 Subject: [PATCH] fix: whisper binary missing in package https://github.com/chidiwilliams/buzz/issues/630#issuecomment-1882934761 --- .run/pytest.run.xml | 30 ++++++++++++++++ Buzz.spec | 59 ++++++++++++++++--------------- buzz/widgets/import_url_dialog.py | 8 ++--- 3 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 .run/pytest.run.xml diff --git a/.run/pytest.run.xml b/.run/pytest.run.xml new file mode 100644 index 0000000000..0876f1362a --- /dev/null +++ b/.run/pytest.run.xml @@ -0,0 +1,30 @@ + + + + + diff --git a/Buzz.spec b/Buzz.spec index d87721ae69..396b7bbcff 100644 --- a/Buzz.spec +++ b/Buzz.spec @@ -5,32 +5,35 @@ import shutil from PyInstaller.utils.hooks import collect_data_files, copy_metadata -from buzz.__version__ import VERSION - datas = [] -datas += collect_data_files('torch') -datas += copy_metadata('tqdm') -datas += copy_metadata('torch') -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 += collect_data_files("torch") +datas += copy_metadata("tqdm") +datas += copy_metadata("torch") +datas += copy_metadata("regex") +datas += copy_metadata("requests") +datas += copy_metadata("packaging") +datas += copy_metadata("filelock") +datas += copy_metadata("numpy") +datas += copy_metadata("tokenizers") # Allow transformers package to load __init__.py file dynamically: # https://github.com/chidiwilliams/buzz/issues/272 -datas += collect_data_files('transformers', include_py_files=True) +datas += collect_data_files("transformers", include_py_files=True) -datas += collect_data_files('whisper') -datas += [(file[1], os.path.dirname(file[1])) for file in - Tree('./locale', prefix='locale', excludes=['*.po'])] -datas += [(shutil.which('ffmpeg'), '.')] +datas += collect_data_files("whisper") +datas += [ + ("buzz/whisper.dll" if platform.system() == "Windows" else "buzz/libwhisper.*", ".") +] +datas += [ + (file[1], os.path.dirname(file[1])) + for file in Tree("./locale", prefix="locale", excludes=["*.po"]) +] +datas += [(shutil.which("ffmpeg"), ".")] block_cipher = None a = Analysis( - ['main.py'], + ["main.py"], pathex=[], binaries=[], datas=datas, @@ -50,9 +53,9 @@ exe = EXE( pyz, a.scripts, [], - icon='./assets/buzz.ico', + icon="./assets/buzz.ico", exclude_binaries=True, - name='Buzz', + name="Buzz", debug=True, bootloader_ignore_signals=False, strip=False, @@ -72,17 +75,17 @@ coll = COLLECT( strip=False, upx=False, upx_exclude=[], - name='Buzz', + name="Buzz", ) app = BUNDLE( coll, - name='Buzz.app', - icon='./assets/buzz.icns', - bundle_identifier='com.chidiwilliams.buzz', - version='0.8.4', + name="Buzz.app", + icon="./assets/buzz.icns", + bundle_identifier="com.chidiwilliams.buzz", + version="0.8.4", info_plist={ - 'NSPrincipalClass': 'NSApplication', - 'NSHighResolutionCapable': 'True', - 'NSMicrophoneUsageDescription': 'Allow Buzz to record audio from your microphone.' - } + "NSPrincipalClass": "NSApplication", + "NSHighResolutionCapable": "True", + "NSMicrophoneUsageDescription": "Allow Buzz to record audio from your microphone.", + }, ) diff --git a/buzz/widgets/import_url_dialog.py b/buzz/widgets/import_url_dialog.py index 4f6e89ada7..5b003cf6d9 100644 --- a/buzz/widgets/import_url_dialog.py +++ b/buzz/widgets/import_url_dialog.py @@ -1,7 +1,7 @@ from typing import Optional from PyQt6.QtCore import Qt, QRegularExpression -from PyQt6.QtWidgets import QDialog, QWidget, QDialogButtonBox, QVBoxLayout, QMessageBox +from PyQt6.QtWidgets import QDialog, QWidget, QDialogButtonBox, QMessageBox, QFormLayout from buzz.locale import _ from buzz.widgets.line_edit import LineEdit @@ -19,7 +19,7 @@ def __init__(self, parent: Optional[QWidget] = None): self.setWindowTitle(_("Import URL")) self.line_edit = LineEdit() - self.line_edit.setPlaceholderText(_("URL")) + self.line_edit.setPlaceholderText(_("https://example.com/audio.mp3")) self.line_edit.setMinimumWidth(350) self.button_box = QDialogButtonBox( @@ -28,8 +28,8 @@ def __init__(self, parent: Optional[QWidget] = None): self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) - self.layout = QVBoxLayout() - self.layout.addWidget(self.line_edit) + self.layout = QFormLayout() + self.layout.addRow(_("URL:"), self.line_edit) self.layout.addWidget(self.button_box) self.setLayout(self.layout)