manylinux_utils.sh 1.29 KB
Newer Older
1
2
3
4
# Useful utilities common across manylinux1 builds

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

6
7
# UNICODE_WIDTH selects "32"=wide (UCS4) or "16"=narrow (UCS2/UTF16) builds
UNICODE_WIDTH="${UNICODE_WIDTH:-32}"
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

function cpython_path {
    # Return path to cpython given
    # * version (of form "2.7")
    # * u_width ("16" or "32" default "32")
    #
    # For back-compatibility "u" as u_width also means "32"
    local py_ver="${1:-2.7}"
    local u_width="${2:-${UNICODE_WIDTH}}"
    local u_suff=u
    # Back-compatibility
    if [ "$u_width" == "u" ]; then u_width=32; fi
    # For Python >= 3.3, "u" suffix not meaningful
    if [ $(lex_ver $py_ver) -ge $(lex_ver 3.3) ] ||
        [ "$u_width" == "16" ]; then
        u_suff=""
    elif [ "$u_width" != "32" ]; then
        echo "Incorrect u_width value $u_width"
        exit 1
    fi
28
    local no_dots=$(echo $py_ver | tr -d .)
29
30
31
32
33
    echo "/opt/python/cp${no_dots}-cp${no_dots}m${u_suff}"
}

function repair_wheelhouse {
    local in_dir=$1
34
    local out_dir=${2:-$in_dir}
35
36
    for whl in $in_dir/*.whl; do
        if [[ $whl == *none-any.whl ]]; then
37
            [ "$in_dir" == "$out_dir" ] || cp $whl $out_dir
38
39
40
41
42
43
        else
            auditwheel repair $whl -w $out_dir/
        fi
    done
    chmod -R a+rwX $out_dir
}