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_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@12'
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 type -f apt > /dev/null 2>&1; then
33
34
35
36
37
38
39
40
41
42
43
44
        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 \
45
        "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" \
46
47
    || exit 1
    sudo mkdir /opt/cmake || exit 1
48
    sudo sh "cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" --skip-license --prefix=/opt/cmake || exit 1
49
50
    sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake || exit 1

51
    if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
52
53
54
55
56
        # 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
57
        sudo apt-get install --no-install-recommends -y \
58
59
            software-properties-common

60
        sudo apt-get install --no-install-recommends -y \
61
62
63
            build-essential \
            git \
            libcurl4 \
64
65
            libicu-dev \
            libssl-dev \
66
            locales \
67
            locales-all || exit 1
68
69
70
71
        if [[ $COMPILER == "clang" ]]; then
            sudo apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
72
        elif [[ $COMPILER == "clang-17" ]]; then
73
74
            sudo apt-get install --no-install-recommends -y \
                wget
75
76
77
78
            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
79
80
81
            sudo apt-get install -y \
                clang-17 \
                libomp-17-dev
82
        fi
83
84

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

145
if [[ "${TASK}" != "r-package" ]]; then
146
    if [[ $SETUP_CONDA != "false" ]]; then
147
148
149
        curl \
            -sL \
            -o miniforge.sh \
150
151
            "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-${ARCH}.sh"
        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