-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall_deps.sh
More file actions
executable file
·182 lines (151 loc) · 4.93 KB
/
Copy pathinstall_deps.sh
File metadata and controls
executable file
·182 lines (151 loc) · 4.93 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
#!/bin/bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1" >&2
}
# Install and configure g++ version
install_gcc() {
log_info "Installing and configuring g++ version..."
# Install gcc-c++ and devtoolset if available
if yum search devtoolset 2>/dev/null | grep -q devtoolset; then
log_info "Installing devtoolset for newer g++ version..."
yum install -y centos-release-scl
yum install -y devtoolset-11-gcc-c++
# Set environment variables globally for this script
export CC=/opt/rh/devtoolset-11/root/usr/bin/gcc
export CXX=/opt/rh/devtoolset-11/root/usr/bin/g++
export PATH=/opt/rh/devtoolset-11/root/usr/bin:$PATH
export LD_LIBRARY_PATH=/opt/rh/devtoolset-11/root/usr/lib64:/opt/rh/devtoolset-11/root/usr/lib:$LD_LIBRARY_PATH
# Create symlinks to make it the default
ln -sf /opt/rh/devtoolset-11/root/usr/bin/gcc /usr/local/bin/gcc
ln -sf /opt/rh/devtoolset-11/root/usr/bin/g++ /usr/local/bin/g++
ln -sf /opt/rh/devtoolset-11/root/usr/bin/gcc /usr/local/bin/cc
ln -sf /opt/rh/devtoolset-11/root/usr/bin/g++ /usr/local/bin/c++
# Add to PATH permanently
echo 'export PATH=/opt/rh/devtoolset-11/root/usr/bin:$PATH' >> /etc/environment
echo 'export LD_LIBRARY_PATH=/opt/rh/devtoolset-11/root/usr/lib64:/opt/rh/devtoolset-11/root/usr/lib:$LD_LIBRARY_PATH' >> /etc/environment
log_info "Using g++ from devtoolset-11: $(g++ --version | head -n1)"
else
log_info "Using system g++: $(g++ --version | head -n1)"
fi
}
# Install CMake
install_cmake() {
log_info "Installing CMake..."
local cmake_version="3.31.0"
local cmake_dir="${HOME}/software/cmake"
pushd /tmp/ >/dev/null
if [[ ! -f "cmake-${cmake_version}-linux-x86_64.sh" ]]; then
wget "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-linux-x86_64.sh"
fi
mkdir -p "${cmake_dir}" 2>/dev/null || true
bash "cmake-${cmake_version}-linux-x86_64.sh" --skip-license --prefix="${cmake_dir}"
# Add to shell config files if not already present
for shell_rc in "${HOME}/.bashrc" "${HOME}/.zshrc"; do
# trunk-ignore(shellcheck/SC2016)
if [[ -f ${shell_rc} ]] && ! grep -q 'PATH=$HOME/software/cmake/bin:$PATH' "${shell_rc}"; then
# trunk-ignore(shellcheck/SC2016)
echo 'export PATH=$HOME/software/cmake/bin:$PATH' >>"${shell_rc}"
fi
done
# Source the updated PATH
export PATH="${cmake_dir}/bin:${PATH}"
popd >/dev/null
}
# Install Zstd from source
install_zstd() {
log_info "Installing Zstd from source..."
local zstd_version="1.5.0"
pushd /tmp/ >/dev/null
if [[ ! -f "zstd-${zstd_version}.tar.gz" ]]; then
wget "https://github.com/facebook/zstd/releases/download/v${zstd_version}/zstd-${zstd_version}.tar.gz"
tar xf "zstd-${zstd_version}.tar.gz"
fi
pushd "zstd-${zstd_version}/build/cmake/" >/dev/null
mkdir -p _build
pushd _build >/dev/null
cmake -G Ninja ..
ninja
ninja install
popd >/dev/null
popd >/dev/null
popd >/dev/null
}
# Install XGBoost from source
install_xgboost() {
log_info "Installing XGBoost from source..."
pushd /tmp/ >/dev/null
if [[ ! -d "xgboost" ]]; then
git clone --recursive https://github.com/dmlc/xgboost
fi
pushd xgboost >/dev/null
mkdir -p build
pushd build >/dev/null
cmake -G Ninja ..
ninja
ninja install
popd >/dev/null
popd >/dev/null
popd >/dev/null
}
# Install LightGBM from source
install_lightgbm() {
log_info "Installing LightGBM from source..."
pushd /tmp/ >/dev/null
if [[ ! -d "LightGBM" ]]; then
git clone --recursive https://github.com/microsoft/LightGBM
fi
pushd LightGBM >/dev/null
mkdir -p build
pushd build >/dev/null
cmake -G Ninja ..
ninja
ninja install
popd >/dev/null
popd >/dev/null
popd >/dev/null
}
# Detect OS and install dependencies
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
log_info "Detected Linux system, installing dependencies via yum..."
# Enable EPEL repository
yum install -y epel-release
# Enable PowerTools/CRB repository
if yum repolist | grep -q powertools; then
yum-config-manager --set-enabled powertools
elif yum repolist | grep -q crb; then
yum-config-manager --set-enabled crb
fi
# Install development tools
yum groupinstall -y "Development Tools"
yum install -y glib2-devel google-perftools-devel
yum install -y ninja-build git wget
# Install and configure g++ version
install_gcc
# Install CMake
install_cmake
# Install dependencies from source
install_zstd
install_xgboost
install_lightgbm
elif [[ "$OSTYPE" == "darwin"* ]]; then
log_info "Detected macOS system, installing dependencies via brew..."
# Install basic dependencies via Homebrew
brew install glib google-perftools argp-standalone xxhash llvm wget cmake ninja zstd xgboost lightgbm
else
log_error "Unsupported operating system: $OSTYPE"
exit 1
fi
log_info "Dependencies installation completed!"