-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·45 lines (34 loc) · 1.14 KB
/
setup.sh
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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Specify the Python version
PYTHON_VERSION=3.12
# Function to install a package if it's not already installed
install_if_not_exists() {
#if ! command -v $1 &> /dev/null; then
if ! dpkg-query -W $1 &> /dev/null; then
echo "$1 could not be found, installing..."
sudo apt-get install -y $1
else
echo "$1 is already installed."
fi
}
# Update package list
sudo apt-get update
# Install Python and necessary packages
install_if_not_exists python$PYTHON_VERSION
install_if_not_exists python${PYTHON_VERSION}-venv
install_if_not_exists python3-pip
# Wipe out the old virtual environment
[ -d .venv ] && rm -rf .venv
# Create a new virtual environment using the specified Python version
python$PYTHON_VERSION -m venv .venv
# Activate the virtual environment
source .venv/bin/activate
# Upgrade pip
pip install --upgrade pip
# Install required Python packages from requirements.txt
[ -f requirements-dev.txt ] && pip install -r requirements-dev.txt || pip install -r requirements.txt
# Deactivate the virtual environment
deactivate
echo "Setup completed successfully."