-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_env_Linux.sh
executable file
·95 lines (75 loc) · 2.62 KB
/
setup_env_Linux.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
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
#!/bin/bash
# Use the current path for the source command
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo $CURRENT_DIR
# Function to install Python, pip, and Jupyter Lab on Manjaro
install_manjaro() {
echo "Installing Python..."
sudo pacman -S --noconfirm python || { echo "Failed to install Python"; exit 1; }
echo "Installing pip..."
sudo pacman -S --noconfirm python-pip
}
# Function to install Python, pip, and Jupyter Lab on Ubuntu
install_ubuntu() {
echo "Installing Python..."
sudo apt-get update
sudo apt-get install -y python3 || { echo "Failed to install Python"; exit 1; }
echo "Installing pip..."
sudo apt-get install -y python3-pip
}
# Function to install Python venv
install_ubuntu_python_venv() {
echo "Installing Python venv..."
sudo apt-get install -y python3-venv # Install Python venv package
}
# Function to install Python venv on Manjaro
install_manjaro_python_venv() {
echo "Installing Python venv on Manjaro..."
sudo pacman -S --noconfirm python-virtualenv # Install Python venv package for Manjaro
}
# Function to create and activate a virtual environment
create_and_activate_venv() {
if [ ! -d "$CURRENT_DIR/linuxPythonVenv" ]; then
echo "Creating a virtual environment..."
python3 -m venv "$CURRENT_DIR/linuxPythonVenv"
else
echo "Removing exising venv and creating a new..."
rm -rf "$CURRENT_DIR/linuxPythonVenv"
python3 -m venv "$CURRENT_DIR/linuxPythonVenv"
fi
echo "Activating virtual environment..."
source "$CURRENT_DIR/linuxPythonVenv/bin/activate"
}
# Determine the Linux distribution. The -f is testing for existing file.
if [ -f /etc/manjaro-release ]; then
echo "Detected Manjaro Linux"
install_manjaro
install_manjaro_python_venv
elif [ -f /etc/lsb-release ]; then
DISTRO=$(lsb_release -si)
if [ "$DISTRO" == "Ubuntu" ]; then
echo "Detected Ubuntu Linux"
install_ubuntu
install_ubuntu_python_venv
else
echo "Unsupported Linux distribution: $DISTRO"
exit 1
fi
else
echo "Unsupported Linux distribution"
exit 1
fi
# Create and activate a virtual environment
create_and_activate_venv
# Install project dependencies from requirements.txt
if [ -f "$CURRENT_DIR/requirements.txt" ]; then
pip install -r "$CURRENT_DIR/requirements.txt"
fi
echo "Libraries installed successfully."
create_project_folders(){
# Create needed project folders
echo "Creating project folders..."
mkdir -p "$CURRENT_DIR/results/gan_results"
mkdir -p "$CURRENT_DIR/results/cnn_results"
}
create_project_folders