Skip to content

Commit 1e8afd7

Browse files
committed
Added Development Setup Script, that setup the development Enviroment
1 parent 5ec378a commit 1e8afd7

File tree

3 files changed

+206
-1
lines changed

3 files changed

+206
-1
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
hooks:
44
- id: version-controller
55
name: Version Controller
6-
entry: ./scripts/versionController.sh
6+
entry: ./scripts/version-hook.sh
77
language: system
88
stages: [commit]
99
pass_filenames: false

development.sh

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
#!/bin/bash
2+
3+
set -e # Exit on any error
4+
5+
echo "🚀 Setting up development environment..."
6+
7+
# Colors for output
8+
RED='\033[0;31m'
9+
GREEN='\033[0;32m'
10+
YELLOW='\033[1;33m'
11+
BLUE='\033[0;34m'
12+
NC='\033[0m' # No Color
13+
14+
# Function to print colored output
15+
print_status() {
16+
echo -e "${BLUE}[INFO]${NC} $1"
17+
}
18+
19+
print_success() {
20+
echo -e "${GREEN}[SUCCESS]${NC} $1"
21+
}
22+
23+
print_warning() {
24+
echo -e "${YELLOW}[WARNING]${NC} $1"
25+
}
26+
27+
print_error() {
28+
echo -e "${RED}[ERROR]${NC} $1"
29+
}
30+
31+
# Check if running as root
32+
if [[ $EUID -eq 0 ]]; then
33+
print_warning "Running as root. Some operations may behave differently."
34+
fi
35+
36+
# Update package lists
37+
print_status "Updating package lists..."
38+
if command -v apt-get &> /dev/null; then
39+
sudo apt-get update -qq
40+
elif command -v yum &> /dev/null; then
41+
sudo yum check-update || true
42+
elif command -v dnf &> /dev/null; then
43+
sudo dnf check-update || true
44+
elif command -v pacman &> /dev/null; then
45+
sudo pacman -Sy
46+
else
47+
print_warning "Package manager not detected. Manual installation may be required."
48+
fi
49+
50+
# Install essential tools
51+
print_status "Installing essential development tools..."
52+
if command -v apt-get &> /dev/null; then
53+
sudo apt-get install -y curl wget git build-essential software-properties-common
54+
elif command -v yum &> /dev/null; then
55+
sudo yum groupinstall -y "Development Tools"
56+
sudo yum install -y curl wget git
57+
elif command -v dnf &> /dev/null; then
58+
sudo dnf groupinstall -y "Development Tools"
59+
sudo dnf install -y curl wget git
60+
elif command -v pacman &> /dev/null; then
61+
sudo pacman -S --noconfirm curl wget git base-devel
62+
fi
63+
64+
# Check if Python3 is available
65+
print_status "Checking Python installation..."
66+
if ! command -v python3 &> /dev/null; then
67+
print_warning "Python3 not found. Installing Python3..."
68+
69+
if command -v apt-get &> /dev/null; then
70+
sudo apt-get install -y python3 python3-pip python3-venv python3-dev
71+
elif command -v yum &> /dev/null; then
72+
sudo yum install -y python3 python3-pip python3-venv python3-devel
73+
elif command -v dnf &> /dev/null; then
74+
sudo dnf install -y python3 python3-pip python3-venv python3-devel
75+
elif command -v pacman &> /dev/null; then
76+
sudo pacman -S --noconfirm python python-pip python-virtualenv
77+
else
78+
print_error "Could not install Python3. Please install manually."
79+
exit 1
80+
fi
81+
else
82+
print_success "Python3 is already installed: $(python3 --version)"
83+
fi
84+
85+
# Check if pip is available
86+
if ! command -v pip3 &> /dev/null && ! python3 -m pip --version &> /dev/null; then
87+
print_warning "pip not found. Installing pip..."
88+
89+
if command -v apt-get &> /dev/null; then
90+
sudo apt-get install -y python3-pip
91+
elif command -v yum &> /dev/null; then
92+
sudo yum install -y python3-pip
93+
elif command -v dnf &> /dev/null; then
94+
sudo dnf install -y python3-pip
95+
else
96+
# Download and install pip manually
97+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
98+
python3 get-pip.py
99+
rm get-pip.py
100+
fi
101+
else
102+
print_success "pip is available"
103+
fi
104+
105+
# Install FFmpeg (required for media processing)
106+
print_status "Checking FFmpeg installation..."
107+
if ! command -v ffmpeg &> /dev/null; then
108+
print_warning "FFmpeg not found. Installing FFmpeg..."
109+
110+
if command -v apt-get &> /dev/null; then
111+
sudo apt-get install -y ffmpeg
112+
elif command -v yum &> /dev/null; then
113+
sudo yum install -y ffmpeg
114+
elif command -v dnf &> /dev/null; then
115+
sudo dnf install -y ffmpeg
116+
elif command -v pacman &> /dev/null; then
117+
sudo pacman -S --noconfirm ffmpeg
118+
else
119+
print_error "Could not install FFmpeg. Please install manually."
120+
exit 1
121+
fi
122+
else
123+
print_success "FFmpeg is already installed: $(ffmpeg -version | head -n1)"
124+
fi
125+
126+
# Create virtual environment
127+
VENV_NAME="venv"
128+
print_status "Creating virtual environment..."
129+
130+
if [ -d "$VENV_NAME" ]; then
131+
print_warning "Virtual environment already exists. Removing old environment..."
132+
rm -rf "$VENV_NAME"
133+
fi
134+
135+
python3 -m venv "$VENV_NAME"
136+
print_success "Virtual environment created: $VENV_NAME"
137+
138+
# Activate virtual environment
139+
print_status "Activating virtual environment..."
140+
source "$VENV_NAME/bin/activate"
141+
print_success "Virtual environment activated"
142+
143+
# Upgrade pip
144+
print_status "Upgrading pip..."
145+
python -m pip install --upgrade pip
146+
147+
# Install requirements
148+
if [ -f "requirements.txt" ]; then
149+
print_status "Installing requirements from requirements.txt..."
150+
python -m pip install -r requirements.txt
151+
print_success "Requirements installed successfully"
152+
else
153+
print_error "requirements.txt not found!"
154+
exit 1
155+
fi
156+
157+
# Install pre-commit if not already installed
158+
if ! command -v pre-commit &> /dev/null; then
159+
print_status "Installing pre-commit..."
160+
python -m pip install pre-commit
161+
print_success "pre-commit installed"
162+
fi
163+
164+
# Install pre-commit hooks
165+
if [ -f ".pre-commit-config.yaml" ]; then
166+
print_status "Installing pre-commit hooks..."
167+
pre-commit install
168+
print_success "Pre-commit hooks installed"
169+
fi
170+
171+
print_success "🎉 Development environment setup complete!"
172+
print_status "To activate the virtual environment in the future, run:"
173+
echo " source $VENV_NAME/bin/activate"
174+
print_status "To deactivate the virtual environment, run:"
175+
echo " deactivate"
176+
177+
# Display environment info
178+
echo ""
179+
print_status "Environment Information:"
180+
echo " Python: $(python --version)"
181+
echo " Pip: $(pip --version)"
182+
echo " Virtual Environment: $(pwd)/$VENV_NAME"
183+
if command -v ffmpeg &> /dev/null; then
184+
echo " FFmpeg: $(ffmpeg -version | head -n1 | cut -d' ' -f3)"
185+
fi
186+
if command -v redis-server &> /dev/null; then
187+
echo " Redis: Available"
188+
fi
189+
190+
echo ""
191+
print_success "You can now start developing! 🚀"

scripts/version-hook.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# Interactive wrapper for version controller in git hooks
4+
# This script properly handles terminal input/output for git hooks
5+
6+
# Check if we're in a git hook environment
7+
if [ -t 0 ] && [ -t 1 ]; then
8+
# We have a proper terminal, run directly
9+
exec "$(dirname "$0")/versionController.sh"
10+
else
11+
# We're in a git hook, need to use terminal properly
12+
exec < /dev/tty > /dev/tty 2>&1
13+
"$(dirname "$0")/versionController.sh"
14+
fi

0 commit comments

Comments
 (0)