travis_linux_steps.sh 2.11 KB
Newer Older
1
2
#!/bin/bash
# Travis steps for Linux
3
set -e
4

5
6
7
ROOT_DIR=$(dirname "${BASH_SOURCE[0]}")
UTIL_DIR=${UTIL_DIR:-${ROOT_DIR}/manylinux}
BUILD_SCRIPT=${BUILD_SCRIPT:-/io/$UTIL_DIR/build_package.sh}
Matthew Brett's avatar
Matthew Brett committed
8
UNICODE_WIDTHS=${UNICODE_WIDTHS:-32}
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

function before_install {
    virtualenv --python=python venv
    source venv/bin/activate
    python --version # just to check
    pip install --upgrade pip wheel
}

function build_wheels {
    # Builds wheel, puts into $WHEELHOUSE
    #
    # Depends on
    #  BUILD_DEPENDS
    #  BUILD_COMMIT
    #  BUILD_PRE_SCRIPT
    #  BUILD_SCRIPT
25
    #  REPO_DIR | PKG_SPEC
26
27
28
29
30
31
32
    #  TRAVIS_PYTHON_VERSION
    #
    # Build both 32- and 64-bit
    build_plat_wheels i686
    build_plat_wheels x86_64
}

Matthew Brett's avatar
Matthew Brett committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function valid_unicode_widths {
    local py_ver=${1:-$TRAVIS_PYTHON_VERSION}
    local ok_widths=""
    if [ "${py_ver:0:1}" == 2 ]; then local py2=1; fi
    for width in ${@:2}; do
        if [ "$width" == 32 ]; then
            ok_widths="$ok_widths 32"
        elif [ "$width" == 16 ]; then
            if [ -n "$py2" ]; then
                ok_widths="$ok_widths 16"
            fi
        else
            echo "Invalid unicode width $width"
            exit 1
        fi
    done
    echo $ok_widths
}

52
53
54
55
56
57
58
59
60
function build_plat_wheels {
    # Builds wheels
    #
    # Depends on
    #
    #  BUILD_DEPENDS  (can be empty)
    #  BUILD_COMMIT
    #  BUILD_PRE_SCRIPT  (can be empty)
    #  BUILD_SCRIPT
61
    #  REPO_DIR | PKG_SPEC
62
63
64
65
    #  TRAVIS_PYTHON_VERSION
    local plat=${1:-x86_64}
    local docker_image=quay.io/pypa/manylinux1_$plat
    docker pull $docker_image
Matthew Brett's avatar
Matthew Brett committed
66
    if [ "$plat" == "i686" ]; then local intro_cmd=linux32; fi
Matthew Brett's avatar
Matthew Brett committed
67
    local widths=$(valid_unicode_widths $TRAVIS_PYTHON_VERSION $UNICODE_WIDTHS)
68
    docker run --rm \
69
70
        -e UTIL_DIR="$UTIL_DIR" \
        -e PYTHON_VERSION="$TRAVIS_PYTHON_VERSION" \
Matthew Brett's avatar
Matthew Brett committed
71
        -e UNICODE_WIDTHS="$widths" \
72
73
74
        -e BUILD_DEPENDS="$BUILD_DEPENDS" \
        -e BUILD_COMMIT="$BUILD_COMMIT" \
        -e BUILD_PRE_SCRIPT="$BUILD_PRE_SCRIPT" \
75
        -e PKG_SPEC="$PKG_SPEC" \
76
        -e REPO_DIR="$REPO_DIR" \
77
78
79
        -v $PWD:/io \
        $docker_image $intro_cmd $BUILD_SCRIPT
}