-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.bash
158 lines (125 loc) · 4.08 KB
/
setup.bash
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
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check the operating system
is_mac() {
[[ "$OSTYPE" == "darwin"* ]]
}
is_windows() {
[[ "$OS" == "Windows_NT" ]]
}
is_ubuntu() {
[[ "$(uname -a)" == *"Ubuntu"* ]]
}
# Logic for macOS
if is_mac; then
echo "Detected macOS"
# Install Homebrew
if ! command_exists brew; then
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "Homebrew is already installed."
fi
# Install Python
if ! command_exists python3; then
echo "Python3 not found. Installing Python3..."
brew install python
else
echo "Python3 is already installed."
fi
# Create a virtual environment
if [ ! -d "env" ]; then
echo "Creating a virtual environment..."
python3 -m venv env
else
echo "Virtual environment already exists."
fi
# Activate the virtual environment
echo "Activating the virtual environment..."
source env/bin/activate
# Upgrade pip and setuptools
echo "Upgrading pip and setuptools..."
pip install --upgrade pip setuptools
# Install required Python packages
echo "Installing required packages..."
pip install -r requirements.txt
brew install libomp
echo "Setup complete. Running the Python script..."
# Run the python script
python3 run.py "Initial Diabetics Data 10000.csv"
# Deactivate the virtual environment
echo "Deactivating the virtual environment..."
deactivate
# Logic for Windows
elif is_windows; then
echo "Detected Windows"
# Check if Python is installed
if ! command_exists python; then
echo "Python not found. Please install Python 3 from https://www.python.org/downloads/ and rerun this script."
exit 1
else
echo "Python is already installed."
fi
# Create a virtual environment
if [ ! -d "env" ]; then
echo "Creating a virtual environment..."
python -m venv env
else
echo "Virtual environment already exists."
fi
# Activate the virtual environment
echo "Activating the virtual environment..."
source env/Scripts/activate
# Upgrade pip and setuptools
echo "Upgrading pip and setuptools..."
pip install --upgrade pip setuptools
# Install required Python packages
echo "Installing required packages..."
pip install -r requirements.txt
echo "Setup complete. Running the Python script..."
# Run the python script
python run.py "Initial Diabetics Data 10000.csv"
# Deactivate the virtual environment
echo "Deactivating the virtual environment..."
deactivate
# Logic for Ubuntu Linux
elif is_ubuntu; then
echo "Detected Ubuntu Linux"
# Update package list and install Python if not installed
if ! command_exists python3; then
echo "Python3 not found. Installing Python3..."
sudo apt-get update
sudo apt-get install -y python3 python3-venv python3-pip
else
echo "Python3 is already installed."
fi
# Create a virtual environment
if [ ! -d "env" ]; then
echo "Creating a virtual environment..."
python3 -m venv env
else
echo "Virtual environment already exists."
fi
# Activate the virtual environment
echo "Activating the virtual environment..."
source env/bin/activate
# Upgrade pip and setuptools
echo "Upgrading pip and setuptools..."
pip install --upgrade pip setuptools
# Install required Python packages
echo "Installing required packages..."
pip install -r requirements.txt
echo "Setup complete. Running the Python script..."
# Run the python script
python3 run.py "Initial Diabetics Data 10000.csv"
# Deactivate the virtual environment
echo "Deactivating the virtual environment..."
deactivate
# Unsupported OS
else
echo "Unsupported operating system. This script only supports macOS, Windows, and Ubuntu Linux."
exit 1
fi