You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

init_image.sh 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash -e
  2. GET_PIP_URL='https://bootstrap.pypa.io/get-pip.py'
  3. GET_PIP_URL_35='https://bootstrap.pypa.io/pip/3.5/get-pip.py'
  4. SWIG_URL='https://codeload.github.com/swig/swig/tar.gz/refs/tags/rel-3.0.12'
  5. LLVM_URL='https://github.com/llvm-mirror/llvm/archive/release_60.tar.gz'
  6. CLANG_URL='https://github.com/llvm-mirror/clang/archive/release_60.tar.gz'
  7. NINJA_URL='https://codeload.github.com/ninja-build/ninja/tar.gz/refs/tags/v1.10.0'
  8. ARCH=$1
  9. echo "ARCH: ${ARCH}"
  10. yum install -y pcre-devel devtoolset-9-libatomic-devel.${ARCH}
  11. yum install -y devtoolset-8 devtoolset-8-libatomic-devel.${ARCH}
  12. # install a default python3 for cmake PYTHON3_EXECUTABLE_WITHOUT_VERSION
  13. yum install -y python3 python3-devel
  14. python3 -m pip install cython
  15. python3 -m pip install numpy
  16. ALL_PYTHON="35m 36m 37m 38"
  17. numpy_version="1.18.1"
  18. if [ ${ARCH} = "aarch64" ];then
  19. # numpy do not have 1.18.1 on aarch64 linux, so we use another fix version
  20. numpy_version="1.19.5"
  21. fi
  22. for ver in ${ALL_PYTHON}
  23. do
  24. python_ver=${ver:0:2}
  25. PIP_URL=${GET_PIP_URL}
  26. if [ ${ver} = "35m" ];then
  27. PIP_URL=${GET_PIP_URL_35}
  28. fi
  29. echo "use pip url: ${PIP_URL}"
  30. curl ${PIP_URL} | /opt/python/cp${python_ver}-cp${ver}/bin/python - \
  31. --no-cache-dir --only-binary :all:
  32. if [ ${ARCH} = "aarch64" ] && [ ${ver} = "35m" ];then
  33. # aarch64 linux python3.5 pip do not provide binary package
  34. /opt/python/cp${python_ver}-cp${ver}/bin/pip install --no-cache-dir numpy setuptools==46.1.3
  35. else
  36. /opt/python/cp${python_ver}-cp${ver}/bin/pip install \
  37. --no-cache-dir --only-binary :all: numpy==${numpy_version} setuptools==46.1.3
  38. fi
  39. done
  40. pushd /home >/dev/null
  41. echo "Install swig"
  42. curl -sSL ${SWIG_URL} | tar xz
  43. pushd swig-rel-3.0.12 >/dev/null
  44. ./autogen.sh
  45. mkdir build
  46. pushd build >/dev/null
  47. ../configure
  48. make -j$(nproc)
  49. make install
  50. popd >/dev/null
  51. popd >/dev/null
  52. rm -rf swig-3.0.12
  53. echo "Install llvm"
  54. curl -sSL ${LLVM_URL} | tar xz
  55. pushd llvm-release_60 >/dev/null
  56. mkdir build
  57. pushd build >/dev/null
  58. cmake .. -DCMAKE_PREFIX_PATH=/opt/python/cp36-cp36m/ \
  59. -DCMAKE_BUILD_TYPE=Release
  60. make -j$(nproc)
  61. make install
  62. popd >/dev/null
  63. popd >/dev/null
  64. rm -rf llvm-release_60
  65. echo "Install clang"
  66. curl -sSL ${CLANG_URL} | tar xz
  67. pushd clang-release_60 >/dev/null
  68. mkdir build
  69. pushd build >/dev/null
  70. cmake .. -DCMAKE_PREFIX_PATH=/opt/python/cp36-cp36m/ \
  71. -DCMAKE_BUILD_TYPE=Release
  72. make -j$(nproc)
  73. make install
  74. popd >/dev/null
  75. popd >/dev/null
  76. rm -rf clang-release_60
  77. echo "Install ninja build"
  78. curl -sSL ${NINJA_URL} | tar xz
  79. pushd ninja-1.10.0 >/dev/null
  80. mkdir build
  81. pushd build >/dev/null
  82. cmake .. -DCMAKE_BUILD_TYPE=Release
  83. make -j$(nproc)
  84. cp ninja /usr/bin/
  85. popd >/dev/null
  86. popd >/dev/null
  87. rm -rf ninja-1.10.0
  88. popd >/dev/null
  89. pushd /tmp >/dev/null
  90. curl -sSL https://github.com/NixOS/patchelf/archive/0.12.tar.gz | tar xz
  91. pushd /tmp/patchelf-0.12 >/dev/null
  92. sed -i '331s/32/256/' ./src/patchelf.cc
  93. ./bootstrap.sh && ./configure && make install-strip
  94. popd
  95. rm -rf /tmp/patchelf-0.12
  96. popd
  97. yum clean all