setup.sh 5.4 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
14
15
if [[ $OS_NAME == "macos" ]]; then
    if  [[ $COMPILER == "clang" ]]; then
        brew install libomp
16
        if [[ $AZURE == "true" ]]; then
17
            sudo xcode-select -s /Applications/Xcode_11.7.app/Contents/Developer || exit 1
18
        fi
Nikita Titov's avatar
Nikita Titov committed
19
    else  # gcc
20
21
22
        # Check https://github.com/actions/runner-images/tree/main/images/macos for available
        # versions of Xcode
        sudo xcode-select -s /Applications/Xcode_14.3.1.app/Contents/Developer || exit 1
23
24
25
26
27
28
29
        if [[ $TASK != "mpi" ]]; then
            brew install gcc
        fi
    fi
    if [[ $TASK == "mpi" ]]; then
        brew install open-mpi
    fi
30
31
    if [[ $TASK == "swig" ]]; then
        brew install swig
32
    fi
33
34
35
    curl \
        -sL \
        -o miniforge.sh \
36
        https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-${ARCH}.sh
37
else  # Linux
38
    if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
39
40
41
42
43
        # 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
44
        sudo apt-get install --no-install-recommends -y \
45
46
            software-properties-common

47
        sudo apt-get install --no-install-recommends -y \
48
49
50
            apt-utils \
            build-essential \
            ca-certificates \
51
            cmake \
52
53
54
55
56
            curl \
            git \
            iputils-ping \
            jq \
            libcurl4 \
57
58
            libicu-dev \
            libssl-dev \
59
60
            libunwind8 \
            locales \
61
            locales-all \
62
63
            netcat \
            unzip \
64
            zip || exit 1
65
66
67
68
        if [[ $COMPILER == "clang" ]]; then
            sudo apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
69
70
71
72
73
74
75
76
        elif [[ $COMPILER == "clang-17" ]]; then
            sudo apt-get install wget
            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
            sudo apt-get install -y clang-17
            sudo apt-get install --no-install-recommends -y libomp-17-dev
77
        fi
78
79

        export LANG="en_US.UTF-8"
80
        sudo update-locale LANG=${LANG}
81
82
        export LC_ALL="${LANG}"
    fi
83
84
85
86
    if [[ $TASK == "r-package" ]] && [[ $COMPILER == "clang" ]]; then
        sudo apt-get install --no-install-recommends -y \
            libomp-dev
    fi
87
    if [[ $TASK == "mpi" ]]; then
88
        if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
89
90
91
92
93
94
95
96
            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 \
97
            || exit 1
98
        fi
99
100
    fi
    if [[ $TASK == "gpu" ]]; then
101
        if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
102
            sudo apt-get update
103
            sudo apt-get install --no-install-recommends -y \
104
                libboost1.74-dev \
105
                libboost-filesystem1.74-dev \
106
                ocl-icd-opencl-dev
107
108
109
110
111
112
        else  # in manylinux image
            sudo yum update -y
            sudo yum install -y \
                boost-devel \
                ocl-icd-devel \
                opencl-headers \
113
            || exit 1
114
        fi
115
    fi
116
    if [[ $TASK == "gpu" || $TASK == "bdist" ]]; then
117
        if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
118
119
120
121
122
123
124
125
            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 \
126
            || exit 1
127
128
        fi
    fi
129
    if [[ $TASK == "cuda" ]]; then
130
        echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
Nikita Titov's avatar
Nikita Titov committed
131
        apt-get update
132
133
        apt-get install --no-install-recommends -y \
            curl \
134
            lsb-release \
135
            software-properties-common
136
137
138
139
140
        if [[ $COMPILER == "clang" ]]; then
            apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
        fi
141
        curl -sL https://apt.kitware.com/keys/kitware-archive-latest.asc | apt-key add -
142
        apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" -y
143
        apt-get update
144
145
        apt-get install --no-install-recommends -y \
            cmake
Nikita Titov's avatar
Nikita Titov committed
146
    fi
147
    if [[ $SETUP_CONDA != "false" ]]; then
148
149
150
151
        curl \
            -sL \
            -o miniforge.sh \
            https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-${ARCH}.sh
152
153
154
    fi
fi

155
if [[ "${TASK}" != "r-package" ]] && [[ "${TASK}" != "r-rchk" ]]; then
156
    if [[ $SETUP_CONDA != "false" ]]; then
157
        sh miniforge.sh -b -p $CONDA
158
159
160
    fi
    conda config --set always_yes yes --set changeps1 no
    conda update -q -y conda
161
fi