-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
195 lines (167 loc) · 5.8 KB
/
setup.py
File metadata and controls
195 lines (167 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
"""
Setup script for Transcribair.
Creates virtual environment and installs all dependencies.
"""
import subprocess
import sys
import os
from pathlib import Path
import platform
def run_command(cmd, description, check=True):
"""Run a command and handle errors."""
print(f"\n{description}...")
print(f"Running: {' '.join(cmd)}")
result = subprocess.run(cmd, capture_output=False)
if check and result.returncode != 0:
print(f"✗ Failed: {description}")
return False
print(f"✓ {description} complete")
return True
def main():
"""Main setup process."""
print("=" * 60)
print("Transcribair Setup")
print("=" * 60)
print("\nThis script will:")
print(" 1. Create a virtual environment")
print(" 2. Install Python dependencies (including LLM providers)")
print(" 3. Set up the application")
print("\nNote: For feedback organization features, you'll need an LLM provider:")
print(" - Ollama (local, recommended): Install from https://ollama.ai")
print(" - OpenAI: Requires API key from platform.openai.com")
print(" - Anthropic: Requires API key from console.anthropic.com")
print()
response = input("Continue? [Y/n]: ").strip().lower()
if response and response not in ['y', 'yes']:
print("Setup cancelled.")
return 1
project_root = Path(__file__).parent
venv_dir = project_root / "venv"
system = platform.system()
# Determine Python command
python_cmd = sys.executable
# Step 1: Create virtual environment
print("\n" + "=" * 60)
print("Step 1: Creating Virtual Environment")
print("=" * 60)
if venv_dir.exists():
print(f"Virtual environment already exists at: {venv_dir}")
response = input("Recreate it? [y/N]: ").strip().lower()
if response in ['y', 'yes']:
import shutil
print("Removing existing virtual environment...")
shutil.rmtree(venv_dir)
else:
print("Using existing virtual environment.")
if not venv_dir.exists():
if not run_command(
[python_cmd, "-m", "venv", str(venv_dir)],
"Creating virtual environment"
):
return 1
# Determine venv Python and pip paths
if system == "Windows":
venv_python = venv_dir / "Scripts" / "python.exe"
venv_pip = venv_dir / "Scripts" / "pip.exe"
activate_script = venv_dir / "Scripts" / "activate.bat"
activate_cmd = str(activate_script)
else:
venv_python = venv_dir / "bin" / "python"
venv_pip = venv_dir / "bin" / "pip"
activate_script = venv_dir / "bin" / "activate"
activate_cmd = f"source {activate_script}"
# Step 2: Upgrade pip
print("\n" + "=" * 60)
print("Step 2: Upgrading pip")
print("=" * 60)
if not run_command(
[str(venv_python), "-m", "pip", "install", "--upgrade", "pip"],
"Upgrading pip"
):
return 1
# Step 3: Install dependencies
print("\n" + "=" * 60)
print("Step 3: Installing Dependencies")
print("=" * 60)
requirements_file = project_root / "requirements.txt"
if not requirements_file.exists():
print("✗ requirements.txt not found!")
return 1
if not run_command(
[str(venv_pip), "install", "-r", str(requirements_file)],
"Installing Python dependencies"
):
return 1
# Step 4: Test installation
print("\n" + "=" * 60)
print("Step 4: Testing Installation")
print("=" * 60)
test_imports = [
"customtkinter",
"faster_whisper",
"sounddevice",
"soundfile",
"ollama",
"openai",
"anthropic",
"reportlab",
"docx"
]
print("Testing imports...")
all_ok = True
for module in test_imports:
result = subprocess.run(
[str(venv_python), "-c", f"import {module}"],
capture_output=True
)
if result.returncode == 0:
print(f" ✓ {module}")
else:
print(f" ✗ {module} - FAILED")
all_ok = False
# Success message
print("\n" + "=" * 60)
print("Setup Complete!")
print("=" * 60)
if all_ok:
print("\n✓ All dependencies installed successfully!")
else:
print("\n⚠ Some dependencies failed to import.")
print(" You may need to troubleshoot the installation.")
print(f"\nVirtual environment created at: {venv_dir}")
print("\nTo activate the virtual environment:")
if system == "Windows":
print(f" {activate_cmd}")
else:
print(f" {activate_cmd}")
print("\nTo run the application:")
if system == "Windows":
print(f" {venv_python} app.py")
print(" or")
print(f" {activate_cmd} && python app.py")
else:
print(f" {venv_python} app.py")
print(" or")
print(f" {activate_cmd} && python app.py")
print("\nTo build the executable:")
print(f" {activate_cmd} && pip install pyinstaller && python build.py")
print("\n" + "=" * 60)
print("Optional: Install Ollama for Local Feedback Organization")
print("=" * 60)
print("\nFor the feedback organization feature, you can:")
print(" 1. Install Ollama (recommended - free, runs locally):")
print(" - Download from: https://ollama.ai")
print(" - After installing, run: ollama pull llama2")
print(" - Configure in app via Settings button")
print("\n 2. Or use cloud providers (OpenAI/Anthropic):")
print(" - Configure API keys in Settings after first launch")
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except KeyboardInterrupt:
print("\n\nSetup cancelled by user.")
sys.exit(1)
except Exception as e:
print(f"\n✗ Setup failed with error: {e}")
sys.exit(1)