-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
166 lines (139 loc) Β· 4.59 KB
/
setup.py
File metadata and controls
166 lines (139 loc) Β· 4.59 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
#!/usr/bin/env python3
"""
Setup script for Messenger AI Assistant
Cross-platform installation and configuration
"""
import subprocess
import sys
import os
import platform
from pathlib import Path
def run_command(command, description, cwd=None):
"""Run a command and handle errors"""
print(f"π {description}...")
try:
result = subprocess.run(
command,
shell=True,
check=True,
capture_output=True,
text=True,
cwd=cwd
)
print(f"β
{description} completed")
return True
except subprocess.CalledProcessError as e:
print(f"β {description} failed: {e}")
if e.stdout:
print(f"Output: {e.stdout}")
if e.stderr:
print(f"Error: {e.stderr}")
return False
def check_python_version():
"""Check if Python version is compatible"""
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 8):
print(f"β Python 3.8+ required, found {version.major}.{version.minor}")
return False
print(f"β
Python {version.major}.{version.minor}.{version.micro} detected")
return True
def check_system_requirements():
"""Check system requirements"""
print("\nπ Checking system requirements...")
system = platform.system()
if system == "Windows":
print("β
Windows detected")
elif system == "Darwin":
print("β
macOS detected")
elif system == "Linux":
print("β
Linux detected")
else:
print(f"β οΈ Unknown system: {system}")
# Check for required tools
tools = ["pip", "python"]
for tool in tools:
try:
subprocess.run([tool, "--version"], check=True, capture_output=True)
print(f"β
{tool} available")
except (subprocess.CalledProcessError, FileNotFoundError):
print(f"β {tool} not found")
return False
return True
def install_dependencies():
"""Install all required dependencies"""
print("\nπ¦ Installing dependencies...")
# Install server dependencies
if not run_command(
"pip install -r requirements.txt",
"Installing server dependencies",
cwd="assist/server"
):
return False
# Install screen capture dependencies
if not run_command(
"pip install -r requirements.txt",
"Installing screen capture dependencies",
cwd="assist/screen_capture"
):
return False
return True
def test_imports():
"""Test if all modules can be imported"""
print("\nπ§ͺ Testing imports...")
tests = [
("assist.server.app", "Backend server"),
("assist.screen_capture.screen_capture", "Screen capture"),
("assist.screen_capture.gui", "GUI"),
]
for module, name in tests:
try:
__import__(module)
print(f"β
{name} imports successfully")
except ImportError as e:
print(f"β {name} import failed: {e}")
return False
return True
def create_directories():
"""Create necessary directories"""
print("\nπ Creating directories...")
directories = [
"assist/screen_capture/capture_output",
"assist/server/uploads",
"assist/server/processed",
"assist/server/logs"
]
for directory in directories:
Path(directory).mkdir(parents=True, exist_ok=True)
print(f"β
Created {directory}")
return True
def main():
"""Main setup function"""
print("π Messenger AI Assistant Setup")
print("=" * 50)
# Check Python version
if not check_python_version():
sys.exit(1)
# Check system requirements
if not check_system_requirements():
print("β System requirements not met")
sys.exit(1)
# Create directories
if not create_directories():
print("β Failed to create directories")
sys.exit(1)
# Install dependencies
if not install_dependencies():
print("β Failed to install dependencies")
sys.exit(1)
# Test imports
if not test_imports():
print("β Import tests failed")
sys.exit(1)
print("\nπ Setup completed successfully!")
print("\nNext steps:")
print(" python assist/launcher.py - Start the complete system")
print(" python assist/server/app.py - Start backend only")
print(" python assist/screen_capture/gui.py - Start GUI only")
print("\nFor help: python assist/launcher.py --help")
if __name__ == "__main__":
main()