-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup.sh
More file actions
executable file
·134 lines (103 loc) · 3.25 KB
/
Copy pathcleanup.sh
File metadata and controls
executable file
·134 lines (103 loc) · 3.25 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
#!/bin/bash
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
log() { echo -e "${BLUE}[*]${NC} $1"; }
success() { echo -e "${GREEN}[+]${NC} $1"; }
error() { echo -e "${RED}[!]${NC} $1"; }
# Function to clean Python packages
clean_python_packages() {
log "Cleaning Python packages..."
if [ -n "$VIRTUAL_ENV" ]; then
# Get list of all installed packages
pip freeze > packages_to_remove.txt
# Core ML packages
pip uninstall -y torch torchvision torchaudio
pip uninstall -y ultralytics mediapipe-silicon face-recognition
pip uninstall -y opencv-python scikit-learn numpy pandas
# Audio packages
pip uninstall -y whisper TTS sounddevice PyAudio
# Web packages
pip uninstall -y fastapi uvicorn python-multipart websockets
# Database packages
pip uninstall -y sqlalchemy alembic
# Utility packages
pip uninstall -y python-dotenv pydantic rich typer
# Development packages
pip uninstall -y pytest black pylint mypy
# Remove remaining packages
pip uninstall -y -r packages_to_remove.txt
rm packages_to_remove.txt
# Clean pip cache
pip cache purge
success "Python packages removed"
else
error "No virtual environment active"
exit 1
fi
}
# Function to clean Homebrew packages
clean_homebrew() {
log "Cleaning Homebrew packages..."
BREW_PACKAGES=(
"cmake"
"ffmpeg"
"portaudio"
"python@3.10"
)
for package in "${BREW_PACKAGES[@]}"; do
if brew list "$package" &>/dev/null; then
brew uninstall "$package"
success "Removed $package"
fi
done
# Clean Homebrew cache
brew cleanup --prune=all
success "Homebrew cleanup complete"
}
# Function to clean system artifacts
clean_system_artifacts() {
log "Cleaning system artifacts..."
# Clean Python cache
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null
# Clean model caches
rm -rf ~/.cache/torch
rm -rf ~/.cache/huggingface
rm -rf ~/.cache/pip
success "System artifacts cleaned"
}
# Function to clean project files
clean_project_files() {
log "Cleaning project files..."
# Deactivate virtual environment
deactivate 2>/dev/null || true
# Remove virtual environment
rm -rf venv
# Remove project directories
rm -rf config jarvis data tests scripts build dist
# Remove configuration files
rm -f .env requirements.txt setup.py .gitignore
rm -f *.log *.db
success "Project files cleaned"
}
# Main cleanup process
main() {
log "Starting comprehensive cleanup..."
if [ -n "$VIRTUAL_ENV" ]; then
clean_python_packages
else
error "Please activate virtual environment first"
exit 1
fi
clean_homebrew
clean_system_artifacts
clean_project_files
success "Cleanup complete!"
}
# Run script
main