161 lines
5.2 KiB
Python
161 lines
5.2 KiB
Python
# -*- mode: python ; coding: utf-8 -*-
|
|
"""PyInstaller spec для упаковки Voice Dictation в .app (macOS).
|
|
|
|
Сборка:
|
|
cd personal/voice-dictation
|
|
source .venv/bin/activate
|
|
pyinstaller scripts/voice_dictation.spec --noconfirm
|
|
|
|
Результат:
|
|
dist/Voice Dictation.app
|
|
"""
|
|
|
|
import os
|
|
import runpy
|
|
from pathlib import Path
|
|
|
|
PROJECT_ROOT = Path(SPECPATH).parent
|
|
SRC = PROJECT_ROOT / "src"
|
|
ICON = PROJECT_ROOT / "assets" / "icons" / "AppIcon.icns"
|
|
RT_HOOK_TK = PROJECT_ROOT / "scripts" / "pyi_rth_tk.py"
|
|
|
|
VERSION = runpy.run_path(str(SRC / "voice_dictation" / "__init__.py"))["__version__"]
|
|
# CFBundleShortVersionString accepts numeric release components only.
|
|
MAC_VERSION = VERSION.split("b")[0]
|
|
BUILD_VERSION = MAC_VERSION + "." + VERSION.split("b")[1]
|
|
LOCAL_WHISPER_CLI = os.environ.get("LOCAL_WHISPER_CLI")
|
|
NATIVE_BINARIES = []
|
|
if LOCAL_WHISPER_CLI:
|
|
executable = Path(LOCAL_WHISPER_CLI).expanduser().resolve(strict=True)
|
|
NATIVE_BINARIES.append((str(executable), "bin"))
|
|
# Keep adjacent runtime dylibs together; PyInstaller also scans dependencies.
|
|
library_dirs = [executable.parent, executable.parent.parent / "lib"]
|
|
library_dirs.extend(
|
|
Path(directory).expanduser().resolve(strict=True)
|
|
for directory in os.environ.get("LOCAL_WHISPER_LIB_DIRS", "").split(os.pathsep)
|
|
if directory
|
|
)
|
|
for directory in library_dirs:
|
|
for pattern in ("*.dylib", "*.so"):
|
|
for library in sorted(directory.glob(pattern)):
|
|
NATIVE_BINARIES.append((str(library), "bin"))
|
|
|
|
block_cipher = None
|
|
|
|
|
|
a = Analysis(
|
|
[str(SRC / "voice_dictation" / "__main__.py")],
|
|
pathex=[str(SRC)],
|
|
binaries=NATIVE_BINARIES,
|
|
datas=[],
|
|
hiddenimports=[
|
|
"voice_dictation",
|
|
"voice_dictation.cli.headless",
|
|
"voice_dictation.ui.settings_cli",
|
|
"voice_dictation.ui.settings_window",
|
|
"voice_dictation.ui.tray",
|
|
"voice_dictation.ui.icons",
|
|
"voice_dictation.ui.splash",
|
|
"voice_dictation.platform.macos.autopaste",
|
|
"voice_dictation.platform.macos.clipboard",
|
|
"voice_dictation.platform.macos.hotkey_listener",
|
|
"voice_dictation.platform.macos.notifier",
|
|
"voice_dictation.platform.macos.sound_player",
|
|
"voice_dictation.platform.macos.system_sounds_scanner",
|
|
"voice_dictation.platform.windows.autopaste",
|
|
"voice_dictation.platform.windows.clipboard",
|
|
"voice_dictation.platform.windows.hotkey_listener",
|
|
"voice_dictation.platform.windows.notifier",
|
|
"voice_dictation.platform.windows.sound_player",
|
|
"voice_dictation.platform.windows.system_sounds_scanner",
|
|
"voice_dictation.core.balance",
|
|
"voice_dictation.core.compressor",
|
|
"voice_dictation.core.fx",
|
|
"voice_dictation.core.usage_db",
|
|
"pkg_resources",
|
|
"pkg_resources.extern",
|
|
"customtkinter",
|
|
"darkdetect",
|
|
"pystray._darwin",
|
|
"PIL._tkinter_finder",
|
|
"sounddevice",
|
|
"openai",
|
|
],
|
|
hookspath=[],
|
|
hooksconfig={},
|
|
runtime_hooks=[str(RT_HOOK_TK)],
|
|
excludes=[
|
|
"tkinter.test",
|
|
"test",
|
|
"unittest",
|
|
"pydoc",
|
|
],
|
|
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,
|
|
[],
|
|
exclude_binaries=True,
|
|
name="VoiceDictation",
|
|
debug=False,
|
|
bootloader_ignore_signals=False,
|
|
strip=False,
|
|
upx=False,
|
|
console=False,
|
|
disable_windowed_traceback=False,
|
|
argv_emulation=False,
|
|
target_arch=None,
|
|
codesign_identity=None,
|
|
entitlements_file=None,
|
|
icon=str(ICON),
|
|
)
|
|
|
|
coll = COLLECT(
|
|
exe,
|
|
a.binaries,
|
|
a.zipfiles,
|
|
a.datas,
|
|
strip=False,
|
|
upx=False,
|
|
upx_exclude=[],
|
|
name="VoiceDictation",
|
|
)
|
|
|
|
app = BUNDLE(
|
|
coll,
|
|
name="Voice Dictation Beta.app",
|
|
icon=str(ICON),
|
|
bundle_identifier="ru.flowmasters.voicedictation.beta",
|
|
version=MAC_VERSION,
|
|
info_plist={
|
|
"CFBundleName": "Voice Dictation Beta",
|
|
"CFBundleDisplayName": "Voice Dictation Beta",
|
|
"CFBundleShortVersionString": MAC_VERSION,
|
|
"CFBundleVersion": BUILD_VERSION,
|
|
"CFBundleIdentifier": "ru.flowmasters.voicedictation.beta",
|
|
"CFBundleExecutable": "VoiceDictation",
|
|
# LSUIElement=true — приложение живёт только в трее, без иконки в Dock
|
|
"LSUIElement": True,
|
|
"NSHighResolutionCapable": True,
|
|
# Минимальная версия macOS (universal2 рантайм)
|
|
"LSMinimumSystemVersion": "11.0",
|
|
# Permissions — пояснения для пользователя
|
|
"NSMicrophoneUsageDescription": (
|
|
"Voice Dictation использует микрофон для записи речи и её "
|
|
"транскрипции через OpenAI Whisper API."
|
|
),
|
|
"NSAppleEventsUsageDescription": (
|
|
"Voice Dictation использует AppleScript для показа уведомлений "
|
|
"и автоматической вставки текста."
|
|
),
|
|
# Локализация
|
|
"CFBundleDevelopmentRegion": "ru_RU",
|
|
},
|
|
)
|