-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_setup.py
More file actions
160 lines (137 loc) · 5.1 KB
/
check_setup.py
File metadata and controls
160 lines (137 loc) · 5.1 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
#!/usr/bin/env python3
"""
Installation and setup verification script.
"""
import sys
import subprocess
from pathlib import Path
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("❌ Python 3.8 or higher is required")
return False
print(f"✅ Python {version.major}.{version.minor}.{version.micro}")
return True
def check_dependencies():
"""Check if required Python packages are installed."""
required_packages = [
'gitpython',
'pydriller',
'click',
'flask',
'flask_cors'
]
missing_packages = []
for package in required_packages:
try:
# Try importing with different possible names
if package == 'flask_cors':
__import__('flask_cors')
elif package == 'gitpython':
__import__('git')
else:
__import__(package)
print(f"✅ {package}")
except ImportError as e:
missing_packages.append(package)
print(f"❌ {package} - {str(e)}")
if missing_packages:
print(f"\nMissing packages: {', '.join(missing_packages)}")
print("Install with: pip install -r requirements.txt")
print("Or if using virtual environment: .venv\\Scripts\\pip.exe install -r requirements.txt")
print("\nNote: Make sure you're running this script with the same Python environment")
print("where you installed the packages.")
return False
return True
def check_git():
"""Check if Git is installed."""
try:
result = subprocess.run(['git', '--version'],
capture_output=True, text=True, check=True)
version = result.stdout.strip()
print(f"✅ {version}")
return True
except (subprocess.CalledProcessError, FileNotFoundError):
print("❌ Git is not installed or not in PATH")
return False
def check_node():
"""Check if Node.js is installed."""
try:
result = subprocess.run(['node', '--version'],
capture_output=True, text=True, check=True)
version = result.stdout.strip()
print(f"✅ Node.js {version}")
# Check npm
result = subprocess.run(['npm', '--version'],
capture_output=True, text=True, check=True)
npm_version = result.stdout.strip()
print(f"✅ npm {npm_version}")
return True
except (subprocess.CalledProcessError, FileNotFoundError):
print("❌ Node.js/npm is not installed or not in PATH")
print(" Download from: https://nodejs.org/")
print(" Or install with: choco install nodejs")
return False
def check_project_structure():
"""Check if project structure is correct."""
required_files = [
'requirements.txt',
'setup.py',
'README.md',
'backend/src/__init__.py',
'backend/src/analyzer.py',
'backend/src/exporter.py',
'backend/src/main.py',
'frontend/package.json',
'frontend/src/App.js',
'frontend/src/index.js',
'cli/src/main.py'
]
missing_files = []
for file_path in required_files:
if not Path(file_path).exists():
missing_files.append(file_path)
print(f"❌ {file_path}")
else:
print(f"✅ {file_path}")
if missing_files:
print(f"\nMissing files: {', '.join(missing_files)}")
return False
return True
def main():
"""Run all checks."""
print("🔍 Checking Codebase Timeline Visualizer setup...\n")
checks = [
("Python Version", check_python_version),
("Git Installation", check_git),
("Node.js Installation", check_node),
("Python Dependencies", check_dependencies),
("Project Structure", check_project_structure)
]
results = []
for name, check_func in checks:
print(f"\n📋 {name}:")
result = check_func()
results.append(result)
print("\n" + "="*50)
if all(results):
print("🎉 All checks passed! You're ready to use Codebase Timeline Visualizer.")
print("\nNext steps:")
print("1. Try the example: python example.py")
print("2. Start the web interface: python -m cli.src.main serve")
print("3. Analyze a repository: python -m cli.src.main analyze /path/to/repo")
print("\nFor development:")
print("- Run tests: python -m pytest backend/tests/")
print("- Start frontend dev server: cd frontend && npm start")
else:
print("❌ Some checks failed. Please fix the issues above and try again.")
print("\nCommon fixes:")
print("- For Python packages: pip install -r requirements.txt")
print("- For Node.js: Install from https://nodejs.org/")
print("- For virtual environment: Use .venv\\Scripts\\python.exe check_setup.py")
print("\nRe-run this script after fixing issues.")
return 1
return 0
if __name__ == '__main__':
exit(main())