init_image.sh 3.2 KB
Newer Older
1 2 3
#!/bin/bash -e

GET_PIP_URL='https://bootstrap.pypa.io/get-pip.py'
4
GET_PIP_URL_35='https://bootstrap.pypa.io/pip/3.5/get-pip.py'
5
SWIG_URL='https://codeload.github.com/swig/swig/tar.gz/refs/tags/rel-3.0.12'
6 7
LLVM_URL='https://github.com/llvm-mirror/llvm/archive/release_60.tar.gz' 
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 10


11 12 13 14
ARCH=$1
echo "ARCH: ${ARCH}"
yum install -y pcre-devel devtoolset-9-libatomic-devel.${ARCH}
yum install -y devtoolset-8 devtoolset-8-libatomic-devel.${ARCH}
15
# install a default python3 for cmake PYTHON3_EXECUTABLE_WITHOUT_VERSION
16 17
yum install -y python3 python3-devel
python3 -m pip install cython
18
python3 -m pip install numpy
19

20 21 22 23 24 25 26
ALL_PYTHON="35m 36m 37m 38"
numpy_version="1.18.1"
if [ ${ARCH} = "aarch64" ];then
    # numpy do not have 1.18.1 on aarch64 linux, so we use another fix version
    numpy_version="1.19.5"
fi
for ver in ${ALL_PYTHON}
27 28
do
    python_ver=${ver:0:2}
29 30 31 32 33 34
    PIP_URL=${GET_PIP_URL}
    if [ ${ver} = "35m" ];then
        PIP_URL=${GET_PIP_URL_35}
    fi
    echo "use pip url: ${PIP_URL}"
    curl ${PIP_URL} | /opt/python/cp${python_ver}-cp${ver}/bin/python - \
35
	--no-cache-dir --only-binary :all:
36 37 38 39 40 41 42
    if [ ${ARCH} = "aarch64" ] && [ ${ver} = "35m" ];then
        # aarch64 linux python3.5 pip do not provide binary package
        /opt/python/cp${python_ver}-cp${ver}/bin/pip install --no-cache-dir numpy setuptools==46.1.3
    else
        /opt/python/cp${python_ver}-cp${ver}/bin/pip install \
        --no-cache-dir --only-binary :all: numpy==${numpy_version} setuptools==46.1.3
    fi
43 44 45 46 47
done

pushd /home >/dev/null
    echo "Install swig"
    curl -sSL ${SWIG_URL} | tar xz
48 49
    pushd swig-rel-3.0.12 >/dev/null
        ./autogen.sh
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
        mkdir build
       	pushd build >/dev/null
	    ../configure
	    make -j$(nproc)
	    make install
        popd >/dev/null
    popd >/dev/null
    rm -rf swig-3.0.12
    
    echo "Install llvm"
    curl -sSL ${LLVM_URL} | tar xz
    pushd llvm-release_60 >/dev/null
        mkdir build
       	pushd build >/dev/null
            cmake .. -DCMAKE_PREFIX_PATH=/opt/python/cp36-cp36m/ \
		-DCMAKE_BUILD_TYPE=Release
	    make -j$(nproc)
	    make install
	popd >/dev/null
    popd >/dev/null
    rm -rf llvm-release_60

    echo "Install clang"
    curl -sSL ${CLANG_URL} | tar xz
    pushd clang-release_60 >/dev/null
        mkdir build
       	pushd build >/dev/null
            cmake .. -DCMAKE_PREFIX_PATH=/opt/python/cp36-cp36m/ \
                -DCMAKE_BUILD_TYPE=Release
	    make -j$(nproc)
	    make install
	popd >/dev/null
    popd >/dev/null
    rm -rf clang-release_60 
84 85 86 87 88 89 90 91 92 93 94
    echo "Install ninja build"
    curl -sSL ${NINJA_URL} | tar xz
    pushd ninja-1.10.0 >/dev/null
        mkdir build
	pushd build >/dev/null
            cmake .. -DCMAKE_BUILD_TYPE=Release
	    make -j$(nproc)
	    cp ninja /usr/bin/
	popd >/dev/null
    popd >/dev/null
    rm -rf ninja-1.10.0
95 96 97 98 99
popd >/dev/null

pushd /tmp >/dev/null
    curl -sSL https://github.com/NixOS/patchelf/archive/0.12.tar.gz | tar xz
    pushd /tmp/patchelf-0.12 >/dev/null
100
        sed -i '331s/32/256/' ./src/patchelf.cc
101 102 103 104 105 106
        ./bootstrap.sh && ./configure && make install-strip
    popd
    rm -rf /tmp/patchelf-0.12
popd

yum clean all