-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·109 lines (86 loc) · 1.77 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·109 lines (86 loc) · 1.77 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
#!/bin/bash
set -e
VENV_VAR=".venv"
#colours
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No colour
# Logging Function (For Log info, Success, Warning, Log error)
log_info(){
echo -e "${BLUE}[INFO] $1${NC}"
}
log_success(){
echo -e "${GREEN}[SUCCESS] $1${NC}"
}
log_warning(){
echo -e "${YELLOW}[WARNING] $1${NC}"
}
log_error(){
echo -e "${RED}[ERROR] $1${NC}"
}
# Enable logs
LOG_FILE="setup.log"
exec > >(tee -a "$LOG_FILE") 2>&1
# Venv function
venv_setup(){
# Ensure python3-venv is available
if ! python3 -m ensurepip --version &>/dev/null
then
log_warning "ensurepip not found. Installing python3-venv..."
sudo apt install -y python3-venv || {
log_error "Failed to install python3-venv. Please run: sudo apt install python3-venv"
exit 1
}
fi
if [ -d ".venv" ]
then
log_info "Virtual environment already exists"
else
log_info "Creating virtual environment..."
python3 -m venv .venv
fi
source .venv/bin/activate
log_success "virtual environment activated"
}
# upgrade pip
upgrade_pip(){
log_info "Upgrading pip..."
pip install --upgrade pip
log_success "pip upgraded successfully"
}
# gitignore
create_gitignore(){
if [ -f ".gitignore" ]
then
log_warning ".gitignore already exists. Skipping..."
else
log_info "Creating .gitignore..."
cat <<EOL > .gitignore
.venv/
__pycache__/
*.pyc
.env
.DS_Store
EOL
log_success ".gitignore created"
fi
}
# install packages
install_packages(){
log_info "Installing required packages..."
pip install pandas requests
log_success "Packages installed successfully"
}
# main
main(){
log_info "Starting project setup..."
venv_setup
upgrade_pip
create_gitignore
install_packages
log_success "Project setup complete!"
}
# Running the scripts
main