-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·138 lines (116 loc) · 3.64 KB
/
setup.sh
File metadata and controls
executable file
·138 lines (116 loc) · 3.64 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
#!/bin/bash
# Setup script for SPH Simulation project
# Works on Ubuntu/Debian, macOS (with Homebrew), and other Linux distributions
set -e
echo "🚀 Setting up SPH Simulation project..."
# Function to detect OS
detect_os() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt-get &> /dev/null; then
echo "ubuntu"
elif command -v yum &> /dev/null; then
echo "rhel"
elif command -v pacman &> /dev/null; then
echo "arch"
else
echo "linux"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
else
echo "unknown"
fi
}
# Function to install system dependencies
install_system_deps() {
local os=$(detect_os)
echo "📦 Installing system dependencies for $os..."
case $os in
ubuntu)
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-venv ffmpeg
;;
rhel)
sudo yum install -y python3 python3-pip ffmpeg
;;
arch)
sudo pacman -S python python-pip ffmpeg
;;
macos)
if command -v brew &> /dev/null; then
brew install python ffmpeg
else
echo "❌ Homebrew not found. Please install Homebrew first:"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
exit 1
fi
;;
*)
echo "⚠️ Unknown OS. Please install Python 3.9+ and FFmpeg manually."
;;
esac
}
# Function to setup Python environment
setup_python_env() {
echo "🐍 Setting up Python virtual environment..."
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Upgrade pip
pip install --upgrade pip
# Install Python dependencies
echo "📚 Installing Python packages..."
pip install -r requirements.txt
echo "✅ Python environment setup complete!"
}
# Function to verify installation
verify_installation() {
echo "🔍 Verifying installation..."
source venv/bin/activate
python3 -c "
import numpy as np
import matplotlib.pyplot as plt
import scipy
import moviepy
print('✅ All Python packages imported successfully!')
print(f'NumPy version: {np.__version__}')
print(f'Matplotlib version: {plt.matplotlib.__version__}')
print(f'SciPy version: {scipy.__version__}')
print(f'MoviePy version: {moviepy.__version__}')
"
# Check ffmpeg
if command -v ffmpeg &> /dev/null; then
echo "✅ FFmpeg is available: $(ffmpeg -version | head -n 1)"
else
echo "⚠️ FFmpeg not found in PATH. Video generation may not work."
fi
}
# Main execution
main() {
# Check if requirements.txt exists
if [[ ! -f "requirements.txt" ]]; then
echo "❌ requirements.txt not found. Please run this script from the project root directory."
exit 1
fi
# Install system dependencies
read -p "Install system dependencies? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
install_system_deps
fi
# Setup Python environment
setup_python_env
# Verify installation
verify_installation
echo ""
echo "🎉 Setup complete!"
echo ""
echo "To activate the environment in the future, run:"
echo " source venv/bin/activate"
echo ""
echo "To run the simulations:"
echo " cd 1/ && python sodshock.py # Sod shock tube simulation"
echo " cd 2/ && python planets.py # Planetary simulation"
}
main "$@"