summaryrefslogtreecommitdiff
path: root/etc/tasks/002-python-packages.sh
blob: 9218a8e3fb790569667152ff1c7660c05cf37875 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -x

# Uses GLOBAL environment variable: PYTHON_VERSION defined by `docker build` argument
prefix="${TOOLCHAIN}"
sysconfdir="${TOOLCHAIN_BUILD}/etc"
reqdir=${sysconfdir}/pip

export PATH="${prefix}/bin:${PATH}"
export PKG_CONFIG_PATH="${prefix}/lib/pkgconfig"
export CFLAGS="-I${prefix}/include"
export LDFLAGS="-L${prefix}/lib -Wl,-rpath=${prefix}/lib"

function pre()
{
    if [[ ! -d ${reqdir} ]]; then
        # Nothing there, but maybe that's on purpose.
        exit 0
    fi
}

function build()
{
    pre
    # Iterate over pip requirement files
    for req in ${reqdir}/*
    do
        pip install --upgrade --progress-bar=off -r "${req}"
        retval=$?
        if [[ ${retval} != 0 ]]; then
            echo "BUILD FAILED: ${req}"
            exit ${retval}
        fi
    done
    post
}

function post()
{
    rm -rf ~/.cache/pip
    [[ -d src ]] && rm -rf src || true
    [[ -f gmon.out ]] && rm -rf gmon.out || true
}

build