setup.sh 5.02 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_13.1.0.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
        brew install gcc
24
25
26
27
    fi
    if [[ $TASK == "mpi" ]]; then
        brew install open-mpi
    fi
28
29
    if [[ $TASK == "swig" ]]; then
        brew install swig
30
    fi
31
else  # Linux
32
    if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
33
34
35
36
37
        # 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
38
        sudo apt-get install --no-install-recommends -y \
39
40
            software-properties-common

41
        sudo apt-get install --no-install-recommends -y \
42
43
            build-essential \
            ca-certificates \
44
            cmake \
45
46
47
            curl \
            git \
            libcurl4 \
48
49
            libicu-dev \
            libssl-dev \
50
            locales \
51
            locales-all || exit 1
52
53
54
55
        if [[ $COMPILER == "clang" ]]; then
            sudo apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
56
        elif [[ $COMPILER == "clang-17" ]]; then
57
58
            sudo apt-get install --no-install-recommends -y \
                wget
59
60
61
62
            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
63
64
65
            sudo apt-get install -y \
                clang-17 \
                libomp-17-dev
66
        fi
67
68

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

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