-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
90 lines (75 loc) · 2.78 KB
/
Copy pathsetup.py
File metadata and controls
90 lines (75 loc) · 2.78 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
#!/usr/bin/env python3
"""
Setup script for Numerical Methods GUI Application
This script helps users set up the environment and install dependencies.
"""
import sys
import subprocess
import os
def check_python_version():
"""Check if Python version is 3.7 or higher"""
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 7):
print("❌ Error: Python 3.7 or higher is required")
print(f" Current version: {version.major}.{version.minor}.{version.micro}")
sys.exit(1)
else:
print(f"✓ Python {version.major}.{version.minor}.{version.micro} detected")
def install_dependencies():
"""Install required dependencies"""
print("\n📦 Installing dependencies...")
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("✓ Dependencies installed successfully")
return True
except subprocess.CalledProcessError:
print("❌ Failed to install dependencies")
return False
def verify_installation():
"""Verify that all packages are installed correctly"""
print("\n🔍 Verifying installation...")
packages = ["numpy", "matplotlib", "sympy"]
all_installed = True
for package in packages:
try:
__import__(package)
print(f"✓ {package} installed")
except ImportError:
print(f"❌ {package} not found")
all_installed = False
return all_installed
def run_application():
"""Run the application"""
print("\n🚀 Launching Numerical Methods GUI...")
try:
subprocess.run([sys.executable, "numerical_methods_gui.py"])
except Exception as e:
print(f"❌ Error launching application: {e}")
def main():
"""Main setup function"""
print("=" * 60)
print(" Numerical Methods GUI - Setup Script")
print("=" * 60)
# Check Python version
check_python_version()
# Install dependencies
if not install_dependencies():
print("\n⚠️ Installation failed. Please install dependencies manually:")
print(" pip install -r requirements.txt")
sys.exit(1)
# Verify installation
if not verify_installation():
print("\n⚠️ Some packages are missing. Please check the installation.")
sys.exit(1)
print("\n" + "=" * 60)
print("✅ Setup completed successfully!")
print("=" * 60)
# Ask if user wants to run the application
response = input("\nWould you like to run the application now? (y/n): ").strip().lower()
if response in ['y', 'yes']:
run_application()
else:
print("\n📝 To run the application later, use:")
print(" python numerical_methods_gui.py")
if __name__ == "__main__":
main()