setup.sh 5.28 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
        sudo xcode-select -s /Applications/Xcode_14.1.app/Contents/Developer || exit 1
21
22
23
24
25
26
27
        if [[ $TASK != "mpi" ]]; then
            brew install gcc
        fi
    fi
    if [[ $TASK == "mpi" ]]; then
        brew install open-mpi
    fi
28
29
    if [[ $TASK == "swig" ]]; then
        brew install swig
30
    fi
31
32
33
    curl \
        -sL \
        -o miniforge.sh \
34
        https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-${ARCH}.sh
35
else  # Linux
36
    if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
37
38
39
40
41
        # 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
42
        sudo apt-get install --no-install-recommends -y \
43
44
            software-properties-common

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

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

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