microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
.github/workflows/scripts/wheelbuilder.sh
51lines · modecode
| 1 | #!/bin/bash |
| 2 | |
| 3 | set -e -x -u |
| 4 | |
| 5 | # CLI arguments |
| 6 | PY_VERSION=$1 |
| 7 | PLAT=$2 |
| 8 | GITHUB_EVENT_NAME=$3 |
| 9 | BUILD_REQUIREMENTS='numpy>=1.18.5 wheel' |
| 10 | |
| 11 | PY_VER="cp${PY_VERSION//./}-cp${PY_VERSION//./}" |
| 12 | if [ ! -d "/opt/python/${PY_VER}" ] |
| 13 | then |
| 14 | PY_VER="${PY_VER}m" |
| 15 | fi |
| 16 | |
| 17 | export PATH=/opt/python/${PY_VER}/bin:$PATH |
| 18 | |
| 19 | # Update pip |
| 20 | pip install --upgrade --no-cache-dir pip |
| 21 | |
| 22 | # Check if requirements were passed |
| 23 | if [ ! -z "$BUILD_REQUIREMENTS" ]; then |
| 24 | pip install --no-cache-dir ${BUILD_REQUIREMENTS} || { echo "Installing requirements failed."; exit 1; } |
| 25 | fi |
| 26 | |
| 27 | # Build wheels |
| 28 | if [ "$GITHUB_EVENT_NAME" == "schedule" ]; then |
| 29 | python setup.py bdist_wheel --nightly_build || { echo "Building wheels failed."; exit 1; } |
| 30 | else |
| 31 | python setup.py bdist_wheel || { echo "Building wheels failed."; exit 1; } |
| 32 | fi |
| 33 | |
| 34 | |
| 35 | # Bundle external shared libraries into the wheels |
| 36 | # find -exec does not preserve failed exit codes, so use an output file for failures |
| 37 | failed_wheels=$PWD/failed-wheels |
| 38 | rm -f "$failed_wheels" |
| 39 | find . -type f -iname "*-linux*.whl" -exec sh -c "auditwheel repair '{}' -w \$(dirname '{}') --plat '${PLAT}' || { echo 'Repairing wheels failed.'; auditwheel show '{}' >> "$failed_wheels"; }" \; |
| 40 | |
| 41 | if [[ -f "$failed_wheels" ]]; then |
| 42 | echo "Repairing wheels failed:" |
| 43 | cat failed-wheels |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | # Remove useless *-linux*.whl; only keep manylinux*.whl |
| 48 | rm -f dist/*-linux*.whl |
| 49 | |
| 50 | echo "Succesfully build wheels:" |
| 51 | find . -type f -iname "*manylinux*.whl" |