-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·100 lines (79 loc) · 3.14 KB
/
setup.sh
File metadata and controls
executable file
·100 lines (79 loc) · 3.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
#!/bin/bash
required_packages=(gcc g++ make python3.8 python3.8-venv python3-pip python3-dev libblas-dev liblapack-dev pybind11-dev rustc openssl libssl-dev libjpeg9 )
pip_packages=(numpy matplotlib scikit-learn pandas scipy cython setuptools_rust)
# Function to check if installation succeeded
post_operations()
{
if [[ $? -eq 0 ]]; then # If last command was successful
echo "$1 installed successfully"
else # If last command returned non zero value
read -p "$1 installation failed, Do you want to continue? (y/n)" answer
if [[ $answer =~ ^([yY][eE][sS]|[yY])$ ]]; then # If user pressed y or Y
echo "Continuing with installation"
else
echo "Exiting" # If user pressed n or N...
exit 1
fi
fi
}
# Function to install a packages
InstallPackage() {
# TODO: Check distribution and install appropriate packages
linux_distro=$(cat /etc/os-release | grep "^ID=" | cut -d '=' -f 2)
if [[ $linux_distro == "ubuntu" ]]; then
sudo apt-get update
sudo apt-get install --no-install-recommends "$@"
fi
}
# Install required packages
echo "Installing required packages"
InstallPackage ${required_packages[@]}
post_operations "Required packages"
# Create python3.8 virtual environment
echo "Creating python3.8 virtual environment in python3.8-env folder"
python3 -m venv python3-env
source python3.8-env/bin/activate
echo "Virtual environment created.."
# Install python libraries
echo "Installing required python libraries..."
pip3 install ${pip_packages[@]}
# check if gcc is present
if [ -z "$(which gcc)" ]; then
echo "gcc is not present, please install it"
exit 2
fi
# Check if "ta-lib-config" is present in PATH
if [ -z "$(which ta-lib-config)" ]; then
echo "ta-lib is not installed. Do you wanted to install it? (y/n)"
read -r answer
# If answer is no then exit
if [[ $answer =~ ^([nN][oO]|[nN])$ ]]; then
echo "ta-lib is not installed. Exiting"
exit 3
fi
source="http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz"
source_file=$(basename $source)
extract_dir="ta-lib"
echo "Using $source_file as source file"
if [ ! -f /tmp/$source_file ]; then # CHeck if source file is already present
echo "$source_file is not present in /tmp, downloading it"
wget $source -O /tmp/$source_file # Download source file
else
echo "$source_file already exists. Using it"
fi
echo "Extracting $source_file into $extract_dir"
tar -xzf /tmp/$source_file # Extract source file
cd $extract_dir
./configure && make -j$(nproc)
post_operations "TA_Lib"
sudo make install # Install TA_Lib into system, need root access!!
post_operations "TA_Lib system"
cd .. && sudo rm -rf $extract_dir # Remove build directory
unset source source_file extract_dir # Delete uneeded variables
else
echo "ta-lib is already installed. Continuing with installation"
fi
# install all packages in requirements.txt
pip install -r requirements.txt
post_operations "requirements"
echo "All required packages are installed successfully!!!"