setup.sh 5.25 KB
Newer Older
1
2
#!/bin/bash

3
4
5
6
7
8
set -e -E -u -o pipefail

# defaults
AZURE=${AZURE:-"false"}
IN_UBUNTU_BASE_CONTAINER=${IN_UBUNTU_BASE_CONTAINER:-"false"}
SETUP_CONDA=${SETUP_CONDA:-"true"}
9

10
11
12
ARCH=$(uname -m)


13
if [[ $OS_NAME == "macos" ]]; then
14
15
16
17
18
19
20
21
22
    # Check https://github.com/actions/runner-images/tree/main/images/macos for available
    # versions of Xcode
    macos_ver=$(sw_vers --productVersion)
    if [[ "${macos_ver}" =~ 13. ]]; then
        xcode_path="/Applications/Xcode_14.3.app/Contents/Developer"
    else
        xcode_path="/Applications/Xcode_15.0.app/Contents/Developer"
    fi
    sudo xcode-select -s "${xcode_path}" || exit 1
23
24
    if  [[ $COMPILER == "clang" ]]; then
        brew install libomp
Nikita Titov's avatar
Nikita Titov committed
25
    else  # gcc
26
        brew install 'gcc@12'
27
28
29
30
    fi
    if [[ $TASK == "mpi" ]]; then
        brew install open-mpi
    fi
31
32
    if [[ $TASK == "swig" ]]; then
        brew install swig
33
    fi
34
else  # Linux
35
    if type -f apt > /dev/null 2>&1; then
36
37
38
39
40
41
42
43
44
45
46
47
        sudo apt-get update
        sudo apt-get install --no-install-recommends -y \
            ca-certificates \
            curl
    else
        sudo yum update -y
        sudo yum install -y \
            ca-certificates \
            curl
    fi
    CMAKE_VERSION="3.30.0"
    curl -O -L \
48
        "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" \
49
50
    || exit 1
    sudo mkdir /opt/cmake || exit 1
51
    sudo sh "cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" --skip-license --prefix=/opt/cmake || exit 1
52
53
    sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake || exit 1

54
    if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
55
56
57
58
59
        # fixes error "unable to initialize frontend: Dialog"
        # https://github.com/moby/moby/issues/27988#issuecomment-462809153
        echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections

        sudo apt-get update
60
        sudo apt-get install --no-install-recommends -y \
61
62
            software-properties-common

63
        sudo apt-get install --no-install-recommends -y \
64
65
66
            build-essential \
            git \
            libcurl4 \
67
68
            libicu-dev \
            libssl-dev \
69
            locales \
70
            locales-all || exit 1
71
72
73
74
        if [[ $COMPILER == "clang" ]]; then
            sudo apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
75
        elif [[ $COMPILER == "clang-17" ]]; then
76
77
            sudo apt-get install --no-install-recommends -y \
                wget
78
79
80
81
            wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
            sudo apt-add-repository deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
            sudo apt-add-repository deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
            sudo apt-get update
82
83
84
            sudo apt-get install -y \
                clang-17 \
                libomp-17-dev
85
        fi
86
87

        export LANG="en_US.UTF-8"
88
        sudo update-locale LANG=${LANG}
89
90
        export LC_ALL="${LANG}"
    fi
91
92
93
94
    if [[ $TASK == "r-package" ]] && [[ $COMPILER == "clang" ]]; then
        sudo apt-get install --no-install-recommends -y \
            libomp-dev
    fi
95
    if [[ $TASK == "mpi" ]]; then
96
        if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
97
98
99
100
101
102
103
104
            sudo apt-get update
            sudo apt-get install --no-install-recommends -y \
                libopenmpi-dev \
                openmpi-bin
        else  # in manylinux image
            sudo yum update -y
            sudo yum install -y \
                openmpi-devel \
105
            || exit 1
106
        fi
107
108
    fi
    if [[ $TASK == "gpu" ]]; then
109
        if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
110
            sudo apt-get update
111
            sudo apt-get install --no-install-recommends -y \
112
                libboost1.74-dev \
113
                libboost-filesystem1.74-dev \
114
                ocl-icd-opencl-dev
115
116
117
118
119
120
        else  # in manylinux image
            sudo yum update -y
            sudo yum install -y \
                boost-devel \
                ocl-icd-devel \
                opencl-headers \
121
            || exit 1
122
        fi
123
    fi
124
    if [[ $TASK == "gpu" || $TASK == "bdist" ]]; then
125
        if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
126
127
128
129
130
131
132
133
            sudo apt-get update
            sudo apt-get install --no-install-recommends -y \
                pocl-opencl-icd
        elif [[ $(uname -m) == "x86_64" ]]; then
            sudo yum update -y
            sudo yum install -y \
                ocl-icd-devel \
                opencl-headers \
134
            || exit 1
135
136
        fi
    fi
137
    if [[ $TASK == "cuda" ]]; then
138
        echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
139
        if [[ $COMPILER == "clang" ]]; then
140
            apt-get update
141
142
143
144
            apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
        fi
Nikita Titov's avatar
Nikita Titov committed
145
    fi
146
147
fi

148
if [[ "${TASK}" != "r-package" ]]; then
149
    if [[ $SETUP_CONDA != "false" ]]; then
150
151
152
        curl \
            -sL \
            -o miniforge.sh \
153
154
            "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-${ARCH}.sh"
        sh miniforge.sh -b -p "${CONDA}"
155
156
157
    fi
    conda config --set always_yes yes --set changeps1 no
    conda update -q -y conda
158
fi