-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_dependencies.py
More file actions
87 lines (70 loc) · 2.65 KB
/
Copy pathvalidate_dependencies.py
File metadata and controls
87 lines (70 loc) · 2.65 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
#!/usr/bin/env python3
"""Validate that all required dependencies are installed and working correctly.
This script checks that all Python packages required for the Computational Physics
2016 scripts are properly installed and can be imported successfully.
"""
import sys
import importlib
def check_dependency(package_name, display_name=None):
"""Check if a package can be imported and return version info."""
if display_name is None:
display_name = package_name
try:
module = importlib.import_module(package_name)
version = getattr(module, '__version__', 'unknown')
print(f"✓ {display_name}: {version}")
return True
except ImportError as e:
print(f"✗ {display_name}: Failed to import ({e})")
return False
def main():
"""Validate all dependencies."""
print("Validating Python dependencies for Computational Physics 2016...")
print("=" * 60)
# Core scientific computing packages
dependencies = [
('numpy', 'NumPy'),
('matplotlib', 'Matplotlib'),
('scipy', 'SciPy'),
('sympy', 'SymPy'),
]
# Additional packages that might be used
optional_dependencies = [
('cycler', 'Cycler'),
('PIL', 'Pillow'),
('dateutil', 'python-dateutil'),
]
success_count = 0
total_count = len(dependencies)
print("\nCore Dependencies:")
print("-" * 30)
for package, display in dependencies:
if check_dependency(package, display):
success_count += 1
print("\nOptional Dependencies:")
print("-" * 30)
for package, display in optional_dependencies:
check_dependency(package, display)
print("\n" + "=" * 60)
if success_count == total_count:
print(f"✓ All {total_count} core dependencies are working correctly!")
print("Your environment is ready for Computational Physics 2016.")
# Test matplotlib backend
try:
import matplotlib.pyplot as plt
plt.figure(figsize=(1, 1))
plt.close()
print("✓ Matplotlib backend is working correctly.")
except Exception as e:
print(f"⚠ Matplotlib backend warning: {e}")
print(" This may affect plot display but scripts should still run.")
return 0
else:
print(f"✗ {total_count - success_count} core dependencies failed!")
print("Please install missing dependencies using:")
print(" pip install -r stable_requirements.txt")
print(" or")
print(" conda env create -f environment.yml")
return 1
if __name__ == "__main__":
sys.exit(main())