|
| 1 | +#!/bin/bash |
| 2 | +set -e -u -x |
| 3 | + |
| 4 | +ARCH=$(uname -m) |
| 5 | +export PLAT=manylinux_2_17_$ARCH |
| 6 | + |
| 7 | +# Accurately check if Python version is 3.8 or greater |
| 8 | +function is_python_version_ge_38 { |
| 9 | + local pydir="$1" |
| 10 | + if [[ $pydir =~ cp([0-9]+)([0-9]+)-cp ]]; then |
| 11 | + local version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}" |
| 12 | + # Use sort with version sort flag to compare version against 3.8 |
| 13 | + if [[ $(echo -e "3.8\n$version" | sort -V | head -n1) == "3.8" ]]; then |
| 14 | + return 0 # True, version is >= 3.8 |
| 15 | + fi |
| 16 | + fi |
| 17 | + return 1 # False, version is < 3.8 |
| 18 | +} |
| 19 | + |
| 20 | +# Compile wheels, only for CPython 3.8+ |
| 21 | +for PYDIR in /opt/python/*; do |
| 22 | + if is_python_version_ge_38 "$PYDIR"; then |
| 23 | + PYBIN="$PYDIR/bin" |
| 24 | + "${PYBIN}/pip" install -r /io/requirements.txt |
| 25 | + "${PYBIN}/pip" wheel /io/ --no-deps -w wheelhouse/ |
| 26 | + fi |
| 27 | +done |
| 28 | + |
| 29 | +# Bundle external shared libraries into the wheels |
| 30 | +for wheel in wheelhouse/*.whl; do |
| 31 | + if auditwheel show "$wheel"; then |
| 32 | + auditwheel repair "$wheel" --plat "$PLAT" -w /io/wheelhouse/ |
| 33 | + fi |
| 34 | +done |
| 35 | + |
| 36 | +# Install packages and test, only for CPython 3.8+ |
| 37 | +for PYDIR in /opt/python/*; do |
| 38 | + if is_python_version_ge_38 "$PYDIR"; then |
| 39 | + PYBIN="$PYDIR/bin" |
| 40 | + "${PYBIN}/pip" install plotpy --no-index -f /io/wheelhouse |
| 41 | + (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") |
| 42 | + fi |
| 43 | +done |
| 44 | + |
0 commit comments