install_deps.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env bash
  2. # Licensed to the LF AI & Data foundation under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. function install_linux_deps() {
  18. if [[ -x "$(command -v apt)" ]]; then
  19. # for Ubuntu 20.04
  20. sudo apt install -y wget curl ca-certificates gnupg2 \
  21. g++ gcc gfortran git make ccache libssl-dev zlib1g-dev zip unzip \
  22. clang-format-12 clang-tidy-12 lcov libtool m4 autoconf automake python3 python3-pip \
  23. pkg-config uuid-dev libaio-dev libopenblas-dev libgoogle-perftools-dev
  24. sudo pip3 install conan==1.64.1
  25. elif [[ -x "$(command -v yum)" ]]; then
  26. # for CentOS devtoolset-11
  27. sudo yum install -y epel-release centos-release-scl-rh
  28. sudo yum install -y wget curl which \
  29. git make automake python3-devel \
  30. devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-gcc-gfortran devtoolset-11-libatomic-devel \
  31. llvm-toolset-11.0-clang llvm-toolset-11.0-clang-tools-extra openblas-devel \
  32. libaio libuuid-devel zip unzip \
  33. ccache lcov libtool m4 autoconf automake
  34. sudo pip3 install conan==1.64.1
  35. echo "source scl_source enable devtoolset-11" | sudo tee -a /etc/profile.d/devtoolset-11.sh
  36. echo "source scl_source enable llvm-toolset-11.0" | sudo tee -a /etc/profile.d/llvm-toolset-11.sh
  37. echo "export CLANG_TOOLS_PATH=/opt/rh/llvm-toolset-11.0/root/usr/bin" | sudo tee -a /etc/profile.d/llvm-toolset-11.sh
  38. source "/etc/profile.d/llvm-toolset-11.sh"
  39. else
  40. echo "Error Install Dependencies ..."
  41. exit 1
  42. fi
  43. # install cmake
  44. cmake_version=$(echo "$(cmake --version | head -1)" | grep -o '[0-9][\.][0-9]*')
  45. if [ ! $cmake_version ] || [ `expr $cmake_version \>= 3.26` -eq 0 ]; then
  46. echo "cmake version $cmake_version is less than 3.26, wait to installing ..."
  47. wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-$(uname -m).tar.gz" | sudo tar --strip-components=1 -xz -C /usr/local
  48. else
  49. echo "cmake version is $cmake_version"
  50. fi
  51. # install rust
  52. if command -v cargo >/dev/null 2>&1; then
  53. echo "cargo exists"
  54. rustup install 1.73
  55. rustup default 1.73
  56. else
  57. bash -c "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=1.73 -y" || { echo 'rustup install failed'; exit 1;}
  58. source $HOME/.cargo/env
  59. fi
  60. }
  61. function install_mac_deps() {
  62. sudo xcode-select --install > /dev/null 2>&1
  63. brew install boost libomp ninja cmake llvm@15 ccache grep pkg-config zip unzip tbb
  64. export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
  65. brew update && brew upgrade && brew cleanup
  66. pip3 install conan==1.64.1
  67. if [[ $(arch) == 'arm64' ]]; then
  68. brew install openssl
  69. brew install librdkafka
  70. fi
  71. sudo ln -s "$(brew --prefix llvm@15)" "/usr/local/opt/llvm"
  72. # install rust
  73. if command -v cargo >/dev/null 2>&1; then
  74. echo "cargo exists"
  75. rustup install 1.73
  76. rustup default 1.73
  77. else
  78. bash -c "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=1.73 -y" || { echo 'rustup install failed'; exit 1;}
  79. source $HOME/.cargo/env
  80. fi
  81. }
  82. if ! command -v go &> /dev/null
  83. then
  84. echo "go could not be found, please install it"
  85. exit
  86. fi
  87. unameOut="$(uname -s)"
  88. case "${unameOut}" in
  89. Linux*) install_linux_deps;;
  90. Darwin*) install_mac_deps;;
  91. *) echo "Unsupported OS:${unameOut}" ; exit 0;
  92. esac