-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_setup.sh
More file actions
executable file
Β·183 lines (159 loc) Β· 5.14 KB
/
project_setup.sh
File metadata and controls
executable file
Β·183 lines (159 loc) Β· 5.14 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
#######################################################
# Script Name: project_setup.sh
# Description: This script sets up a Python project by
# being called by .devcontainer/devcontainer.json,
# creating a virtual environment,
# installing dependencies, and performing
# other project-specific actions.
# Author: Karthick Jayaraman
# Date: 24-01-2023
# Last Modified: 10-12-2023
# Contact: karthick840@yahoo.in
#######################################################
# Function to create virtual environment
create_virtual_environment() {
if [ ! -d ".venv" ]; then
echo
echo "---------------------------------------------"
echo "π Creating virtual environment...π"
echo "---------------------------------------------"
echo
python3 -m venv .venv || { echo "β Failed to create virtual environment .venv"; return 1; }
else
echo
echo "π Virtual environment .venv already present. Skipping this action"
echo
fi
}
# Function to activate virtual environment
activate_virtual_environment() {
echo
if [ -f ".venv/bin/activate" ]; then
echo
echo "---------------------------------------------"
echo "π Activating virtual environment...π"
echo "---------------------------------------------"
echo
source .venv/bin/activate || { echo "β Failed to activate virtual environment .venv"; return 1; }
echo "Virtual environment activated."
else
echo "Failed to find the virtual environment activation script."
return 1
fi
}
# Function to upgrade pip
upgrade_pip() {
echo "Upgrading pip..."
pip install --upgrade pip
}
# Function to install requirements
install_requirements() {
echo
echo "---------------------------------------------"
echo "β
π Installing Dependencies π§"
echo "---------------------------------------------"
echo
if [ -f "requirements.txt" ]; then
echo "Installing packages from requirements.txt..."
pip install -r requirements.txt
else
echo "requirements.txt not found, skipping package installation."
fi
}
# Function to clone and install My_Toolbox repository
install_my_toolbox() {
local repo_url="https://github.com/Karthick-840/My_Toolbox.git"
local repo_dir="My_Toolbox"
echo
echo "---------------------------------------------"
echo "π§ Installing My_Toolbox Repository π§"
echo "---------------------------------------------"
echo
if [ -d "$repo_dir" ]; then
echo "Directory $repo_dir already exists. Deleting it..."
rm -rf "$repo_dir"
fi
echo "Cloning repository from $repo_url into $repo_dir..."
if git clone "$repo_url" "$repo_dir"; then
echo "Repository cloned successfully."
echo "Installing the cloned repository from $repo_dir..."
if cd "$repo_dir"; then
if pip install .; then
echo "Repository installed successfully."
else
echo "β Failed to install the cloned repository"
return 1
fi
else
echo "β Failed to navigate to $repo_dir"
return 1
fi
else
echo "β Failed to clone repository"
return 1
fi
}
# Function to check for the presence of the credentials file
check_credentials_file() {
echo "Checking for credentials file..."
if [ ! -f "client_secrets.json" ]; then
echo "Error: client_secrets.json file not found. Please upload your credentials."
exit 1
else
echo "Credentials file found."
fi
}
# Function to display creation log
display_creation_log() {
echo
echo "Displaying creation log:"
cat /workspaces/.codespaces/.persistedshare/creation.log
echo
}
main() {
echo
echo "---------------------------------------------"
echo "π Setting up Python Virtual Environment π"
echo "----------------------------------------------"
echo
if create_virtual_environment; then
echo "β
Virtual environment created successfully."
else
echo "β Failed to create virtual environment."
exit 1
fi
if activate_virtual_environment; then
echo "β
Virtual environment activated successfully."
else
echo "β Failed to activate virtual environment."
exit 1
fi
if upgrade_pip; then
echo "β
Pip upgraded successfully."
else
echo "β Failed to upgrade pip."
exit 1
fi
if install_my_toolbox; then
echo "β
Toolbox installed successfully."
else
echo "β Failed to install toolbox."
exit 1
fi
if install_requirements; then
echo "β
Requirements installed successfully."
else
echo "β Failed to install requirements."
exit 1
fi
if check_credentials_file; then
echo "β
Credentials file checked successfully."
else
echo "β Failed to check credentials file."
exit 1
fi
echo -e "β
Virtual environment setup complete."
}
# Execute main function
main