-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
57 lines (47 loc) · 2.03 KB
/
setup.py
File metadata and controls
57 lines (47 loc) · 2.03 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
#!/usr/bin/env python
import os
import subprocess
import sys
def check_python_version():
"""Check if Python version is compatible."""
required_version = (3, 8)
current_version = sys.version_info
if current_version < required_version:
sys.exit(f"Python {required_version[0]}.{required_version[1]} or higher is required. You have {current_version[0]}.{current_version[1]}")
print(f"✓ Python version check passed: {current_version[0]}.{current_version[1]}")
def install_requirements():
"""Install required packages."""
try:
print("Installing required packages...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("✓ Packages installed successfully!")
except subprocess.CalledProcessError:
sys.exit("Failed to install required packages. Please check your internet connection and try again.")
def initialize_database():
"""Initialize the database."""
try:
print("Initializing the database...")
if not os.path.exists('services'):
sys.exit("Services directory not found. Make sure you're running this script from the project root.")
# Import and use the initialize_database function
from services.init_db import initialize_database
initialize_database()
print("✓ Database initialized successfully!")
except ImportError as e:
sys.exit(f"Failed to import database initialization module: {e}")
except Exception as e:
sys.exit(f"Failed to initialize database: {e}")
def main():
"""Main setup function."""
print("=== GrapeVine Project Setup ===\n")
check_python_version()
install_requirements()
initialize_database()
print("\n=== Setup Complete! ===")
print("To start the server, run:")
print(" uvicorn main:app --reload")
print("\nThe API will be available at:")
print(" http://localhost:8000")
print(" Documentation: http://localhost:8000/docs")
if __name__ == "__main__":
main()