setup.sh 5.2 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
else  # Linux
34
    if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
35
36
37
38
39
        # 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
40
        sudo apt-get install --no-install-recommends -y \
41
42
            software-properties-common

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

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

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