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.4 kB

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