manylinux_utils.sh 1.85 KB
Newer Older
1
#!/bin/bash
2
3
4
5
# Useful utilities common across manylinux1 builds

MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
source $MULTIBUILD_DIR/common_utils.sh
6

Matthew Brett's avatar
Matthew Brett committed
7
8
9
10
11
function get_platform {
    # Report platform as given by uname
    python -c 'import platform; print(platform.uname()[4])'
}

12
13
function repair_wheelhouse {
    local in_dir=$1
14
    local out_dir=${2:-$in_dir}
15
    for whl in $in_dir/*.whl; do
16
17
        if [[ $whl == *none-any.whl ]]; then  # Pure Python wheel
            if [ "$in_dir" != "$out_dir" ]; then cp $whl $out_dir; fi
18
        else
19
            wheel_count=$(find $out_dir -name *.whl | wc -l)
20
            auditwheel repair $whl -w $out_dir/
21
22
23
24
            if [[ $(find $out_dir -name *.whl | wc -l) -gt $wheel_count ]]; then
                # Remove unfixed if writing into same directory
                if [ "$in_dir" == "$out_dir" ]; then rm $whl; fi
            fi
25
26
27
28
        fi
    done
    chmod -R a+rwX $out_dir
}
xoviat's avatar
xoviat committed
29
30
31

function activate_ccache {
    # Link up the correct location for ccache
xoviat's avatar
xoviat committed
32
    mkdir -p /parent-home/.ccache
xoviat's avatar
xoviat committed
33
34
35
    ln -s /parent-home/.ccache $HOME/.ccache

    # Now install ccache
36
    suppress yum_install ccache
xoviat's avatar
xoviat committed
37
38
39
40
41
42

    # Create fake compilers and prepend them to the PATH
    # Note that yum is supposed to create these for us,
    # but I had trouble finding them
    local ccache_dir=/usr/lib/ccache/compilers
    mkdir -p $ccache_dir
xoviat's avatar
xoviat committed
43
44
45
46
47
    ln -s /usr/bin/ccache $ccache_dir/gcc
    ln -s /usr/bin/ccache $ccache_dir/g++
    ln -s /usr/bin/ccache $ccache_dir/cc
    ln -s /usr/bin/ccache $ccache_dir/c++
    export PATH=$ccache_dir:$PATH
xoviat's avatar
xoviat committed
48
49

    # Prove to the developer that ccache is activated
xoviat's avatar
xoviat committed
50
    echo "Using C compiler: $(which gcc)"
xoviat's avatar
xoviat committed
51
}
52
53
54
55
56
function yum_install {
    # CentOS 5 yum doesn't fail in some cases, e.g. if package is not found
    # https://serverfault.com/questions/694942/yum-should-error-when-a-package-is-not-available
    yum install -y "$1" && rpm -q "$1"
}