setup.sh 5.33 KB
Newer Older
1
2
#!/bin/bash

3
4
5
6
7
set -e -E -u -o pipefail

# defaults
IN_UBUNTU_BASE_CONTAINER=${IN_UBUNTU_BASE_CONTAINER:-"false"}
SETUP_CONDA=${SETUP_CONDA:-"true"}
8

9
10
11
ARCH=$(uname -m)


12
if [[ $OS_NAME == "macos" ]]; then
13
14
15
16
17
18
19
20
21
    # Check https://github.com/actions/runner-images/tree/main/images/macos for available
    # versions of Xcode
    macos_ver=$(sw_vers --productVersion)
    if [[ "${macos_ver}" =~ 13. ]]; then
        xcode_path="/Applications/Xcode_14.3.app/Contents/Developer"
    else
        xcode_path="/Applications/Xcode_15.0.app/Contents/Developer"
    fi
    sudo xcode-select -s "${xcode_path}" || exit 1
22
23
    if  [[ $COMPILER == "clang" ]]; then
        brew install libomp
Nikita Titov's avatar
Nikita Titov committed
24
    else  # gcc
25
        brew install 'gcc@14'
26
27
28
29
    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 type -f apt > /dev/null 2>&1; then
35
36
37
38
39
40
41
42
43
44
45
46
        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 \
47
        "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" \
48
49
    || exit 1
    sudo mkdir /opt/cmake || exit 1
50
    sudo sh "cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" --skip-license --prefix=/opt/cmake || exit 1
51
52
    sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake || exit 1

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

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

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

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

    # print output of 'conda info', to help in submitting bug reports
    echo "conda info:"
    conda info
161
fi