-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
147 lines (115 loc) Β· 4.17 KB
/
Copy pathsetup.py
File metadata and controls
147 lines (115 loc) Β· 4.17 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
#!/usr/bin/env python3
"""
Setup script for the Vision-based Personal Memory Assistant.
This script helps set up the environment and dependencies.
"""
import os
import sys
import subprocess
from pathlib import Path
def run_command(command, description):
"""Run a command and handle errors."""
print(f"π {description}...")
try:
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
print(f"β
{description} completed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"β {description} failed: {e}")
print(f"Error output: {e.stderr}")
return False
def check_python_version():
"""Check if Python version is compatible."""
print("π Checking Python version...")
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 8):
print(f"β Python {version.major}.{version.minor} is not supported. Please use Python 3.8 or higher.")
return False
print(f"β
Python {version.major}.{version.minor}.{version.micro} is compatible")
return True
def install_dependencies():
"""Install required dependencies."""
print("π¦ Installing dependencies...")
# Check if requirements.txt exists
if not Path("requirements.txt").exists():
print("β requirements.txt not found")
return False
# Install dependencies
if not run_command("pip install -r requirements.txt", "Installing Python dependencies"):
return False
# Install spaCy model
if not run_command("python -m spacy download en_core_web_sm", "Installing spaCy English model"):
return False
return True
def create_env_file():
"""Create .env file from template."""
print("π§ Setting up environment configuration...")
env_example = Path("env_example.txt")
env_file = Path(".env")
if not env_example.exists():
print("β env_example.txt not found")
return False
if env_file.exists():
print("β οΈ .env file already exists, skipping creation")
return True
# Copy template to .env
try:
with open(env_example, 'r') as src:
content = src.read()
with open(env_file, 'w') as dst:
dst.write(content)
print("β
.env file created from template")
print("β οΈ Please edit .env file and add your OpenAI API key")
return True
except Exception as e:
print(f"β Failed to create .env file: {e}")
return False
def create_directories():
"""Create necessary directories."""
print("π Creating directories...")
directories = [
"data/images",
"data/database",
"data/embeddings"
]
for directory in directories:
Path(directory).mkdir(parents=True, exist_ok=True)
print(f"β
Created directory: {directory}")
return True
def run_tests():
"""Run the test script to verify setup."""
print("π§ͺ Running tests...")
if not Path("test_setup.py").exists():
print("β test_setup.py not found")
return False
return run_command("python test_setup.py", "Running setup tests")
def main():
"""Main setup function."""
print("π§ Vision-based Personal Memory Assistant Setup")
print("=" * 50)
# Check Python version
if not check_python_version():
return False
# Create directories
if not create_directories():
return False
# Create .env file
if not create_env_file():
return False
# Install dependencies
if not install_dependencies():
return False
# Run tests
if not run_tests():
print("β οΈ Tests failed, but setup may still work")
print("\n" + "=" * 50)
print("π Setup completed!")
print("\nπ Next steps:")
print("1. Edit .env file and add your OpenAI API key")
print("2. Run: streamlit run app.py")
print("3. Open your browser to the URL shown")
print("\nπ‘ For help, see README.md")
return True
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)