File: build-wheels.sh

package info (click to toggle)
plotpy 2.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 13,364 kB
  • sloc: python: 37,833; cpp: 2,005; sh: 32; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 1,460 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
set -e -u -x

ARCH=$(uname -m)
export PLAT=manylinux_2_24_$ARCH

# Accurately check if Python version is 3.9 or greater
function is_python_version_ge_39 {
    local pydir="$1"
    if [[ $pydir =~ cp([0-9]+)([0-9]+)-cp ]]; then
        local version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
        # Use sort with version sort flag to compare version against 3.9
        if [[ $(echo -e "3.9\n$version" | sort -V | head -n1) == "3.9" ]]; then
            return 0  # True, version is >= 3.9
        fi
    fi
    return 1  # False, version is < 3.9
}

# Compile wheels, only for CPython 3.9+
for PYDIR in /opt/python/*; do
    if is_python_version_ge_39 "$PYDIR"; then
        PYBIN="$PYDIR/bin"
        "${PYBIN}/pip" install -r /io/requirements.txt
        "${PYBIN}/pip" wheel /io/ --no-deps -w wheelhouse/
    fi
done

# Bundle external shared libraries into the wheels
for wheel in wheelhouse/*.whl; do
    if auditwheel show "$wheel"; then
        auditwheel repair "$wheel" --plat "$PLAT" -w /io/wheelhouse/
    fi
done

# Install packages and test, only for CPython 3.9+
for PYDIR in /opt/python/*; do
    if is_python_version_ge_39 "$PYDIR"; then
        PYBIN="$PYDIR/bin"
        "${PYBIN}/pip" install plotpy --no-index -f /io/wheelhouse
        (cd "$HOME"; INSTDIR=$("${PYBIN}/python" -c "import plotpy, os.path as osp; print(osp.dirname(plotpy.__file__))"); export QT_QPA_PLATFORM=offscreen; "${PYBIN}/pytest" "$INSTDIR")
    fi
done