summaryrefslogtreecommitdiff
path: root/ci/manylinux.sh
blob: 1fafec9dede9611a4ee9970d26bf309b1e43fb2f (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# From: https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh
# which is in the public domain.
#
# This is run inside a CentOS 5 virtual machine to build manylinux wheels:
#
#   $ docker run -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/ci/build_manylinux.sh
#

set -e -x

action=$1
shift

if [[ $action == "build" ]]; then
    # Compile wheels
    cd /io
    for PYBIN in /opt/python/*/bin; do
        if [[ $PYBIN == *cp34* ]]; then
            # manylinux docker images have Python 3.4, but we don't use it.
            continue
        fi
        "$PYBIN/pip" install -r requirements/wheel.pip
        "$PYBIN/python" setup.py clean -a
        "$PYBIN/python" setup.py bdist_wheel -d ~/wheelhouse/
    done
    cd ~

    # Bundle external shared libraries into the wheels
    for whl in wheelhouse/*.whl; do
        auditwheel repair "$whl" -w /io/dist/
    done

elif [[ $action == "test" ]]; then
    # Create "pythonX.Y" links
    for PYBIN in /opt/python/*/bin/; do
        if [[ $PYBIN == *cp34* ]]; then
            # manylinux docker images have Python 3.4, but we don't use it.
            continue
        fi
        PYNAME=$("$PYBIN/python" -c "import sys; print('python{0[0]}.{0[1]}'.format(sys.version_info))")
        ln -sf "$PYBIN/$PYNAME" /usr/local/bin/$PYNAME
    done

    # Install packages and test
    TOXBIN=/opt/python/cp36-cp36m/bin
    "$TOXBIN/pip" install -r /io/requirements/tox.pip

    cd /io
    export PYTHONPYCACHEPREFIX=/opt/pyc
    if [[ $1 == "meta" ]]; then
        shift
        export COVERAGE_COVERAGE=yes
    fi
    TOXWORKDIR=.tox/linux "$TOXBIN/tox" "$@" || true
    cd ~

else
    echo "Need an action to perform!"
fi