travis_linux_steps.sh 3.86 KB
Newer Older
1
#!/bin/bash
2
# Wheel build, install, run test steps on Linux
3
4
5
#
# In fact the main work is to wrap up the real functions in docker commands.
# The real work is in the BUILD_SCRIPT (which builds the wheel) and
6
# `docker_install_run.sh`, which can be configured with `config.sh`.
7
8
9
10
11
#
# Must define
#  before_install
#  build_wheel
#  install_run
12
set -e
13

14
15
MANYLINUX_URL=${MANYLINUX_URL:-https://nipy.bic.berkeley.edu/manylinux}

16
# Get our own location on this filesystem
17
MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
18

19
20
21
# Allow travis Python version as proxy for multibuild Python version
MB_PYTHON_VERSION=${MB_PYTHON_VERSION:-$TRAVIS_PYTHON_VERSION}

22
function before_install {
23
    # Install a virtualenv to work in.
24
25
26
27
28
29
    virtualenv --python=python venv
    source venv/bin/activate
    python --version # just to check
    pip install --upgrade pip wheel
}

30
31
function build_wheel {
    # Builds wheel, puts into $WHEEL_SDIR
32
    #
33
34
    # In fact wraps the actual work which happens in the container.
    #
35
    # Depends on
36
37
    #     REPO_DIR  (or via input argument)
    #     PLAT (can be passed in as argument)
38
    #     MB_PYTHON_VERSION
39
    #     BUILD_COMMIT
40
41
42
43
44
45
46
    #     UNICODE_WIDTH (optional)
    #     BUILD_DEPENDS (optional)
    #     MANYLINUX_URL (optional)
    #     WHEEL_SDIR (optional)
    local repo_dir=${1:-$REPO_DIR}
    [ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
    local plat=${2:-$PLAT}
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    build_multilinux $plat "build_wheel $repo_dir"
}

function build_index_wheel {
    # Builds wheel from an index (e.g pypi), puts into $WHEEL_SDIR
    #
    # In fact wraps the actual work which happens in the container.
    #
    # Depends on
    #     PLAT (can be passed in as argument)
    #     MB_PYTHON_VERSION
    #     UNICODE_WIDTH (optional)
    #     BUILD_DEPENDS (optional)
    #     MANYLINUX_URL (optional)
    #     WHEEL_SDIR (optional)
    local project_spec=$1
    [ -z "$project_spec" ] && echo "project_spec not defined" && exit 1
    local plat=${2:-$PLAT}
    build_multilinux $plat "build_index_wheel $project_spec"
}

function build_multilinux {
    # Runs passed build commands in manylinux container
    #
    # Depends on
    #     MB_PYTHON_VERSION
    #     UNICODE_WIDTH (optional)
    #     BUILD_DEPENDS (optional)
    #     MANYLINUX_URL (optional)
    #     WHEEL_SDIR (optional)
    local plat=$1
    [ -z "$plat" ] && echo "plat not defined" && exit 1
    local build_cmds="$2"
80
    local docker_image=quay.io/pypa/manylinux1_$plat
81
    retry docker pull $docker_image
82
    docker run --rm \
83
        -e BUILD_COMMANDS="$build_cmds" \
84
        -e PYTHON_VERSION="$MB_PYTHON_VERSION" \
85
        -e UNICODE_WIDTH="$UNICODE_WIDTH" \
86
        -e BUILD_COMMIT="$BUILD_COMMIT" \
87
        -e WHEEL_SDIR="$WHEEL_SDIR" \
88
        -e MANYLINUX_URL="$MANYLINUX_URL" \
89
        -e BUILD_DEPENDS="$BUILD_DEPENDS" \
xoviat's avatar
xoviat committed
90
        -e USE_CCACHE="$USE_CCACHE" \
91
        -e REPO_DIR="$repo_dir" \
92
        -e PLAT="$PLAT" \
93
        -v $PWD:/io \
xoviat's avatar
xoviat committed
94
        -v $HOME:/parent-home \
95
        $docker_image /io/$MULTIBUILD_DIR/docker_build_wrap.sh
96
}
97
98

function install_run {
99
100
101
102
103
104
    # Install wheel, run tests
    #
    # In fact wraps the actual work which happens in the container.
    #
    # Depends on
    #  PLAT (can be passed in as argument)
105
    #  MB_PYTHON_VERSION
106
107
108
109
    #  UNICODE_WIDTH (optional)
    #  WHEEL_SDIR (optional)
    #  MANYLINUX_URL (optional)
    #  TEST_DEPENDS  (optional)
Matthew Brett's avatar
Matthew Brett committed
110
    local plat=${1:-$PLAT}
111
    bitness=$([ "$plat" == i686 ] && echo 32 || echo 64)
112
113
114
    local docker_image="matthewbrett/trusty:$bitness"
    docker pull $docker_image
    docker run --rm \
115
        -e PYTHON_VERSION="$MB_PYTHON_VERSION" \
116
        -e MB_PYTHON_VERSION="$MB_PYTHON_VERSION" \
117
118
119
120
121
        -e UNICODE_WIDTH="$UNICODE_WIDTH" \
        -e WHEEL_SDIR="$WHEEL_SDIR" \
        -e MANYLINUX_URL="$MANYLINUX_URL" \
        -e TEST_DEPENDS="$TEST_DEPENDS" \
        -v $PWD:/io \
122
        $docker_image /io/$MULTIBUILD_DIR/docker_test_wrap.sh
123
}