File size: 2,509 Bytes
065fee7 |
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
#!/bin/bash
if [ -n "$DEBUG" ]
then
set -x
fi
package_name="$1"
if [ -z "$package_name" ]
then
>&2 echo "Please pass package name as a first argument of this script ($0)"
exit 1
fi
export WORKDIR_PATH="${GITHUB_WORKSPACE:-/io}"
BUILD_DIR=`mktemp -d "/tmp/${package_name}-manylinux2010-build.XXXXXXXXXX"`
ORIG_WHEEL_DIR="${BUILD_DIR}/original-wheelhouse"
SRC_DIR="${BUILD_DIR}/src"
WHEELHOUSE_DIR="${WORKDIR_PATH}/dist"
set -euo pipefail
# ref: https://coderwall.com/p/fkfaqq/safer-bash-scripts-with-set-euxo-pipefail
PYTHON_VERSIONS="cp36-cp36m cp37-cp37m"
# Avoid creation of __pycache__/*.py[c|o]
export PYTHONDONTWRITEBYTECODE=1
arch=`uname -m`
echo
echo
echo "Copying source to ${SRC_DIR}..."
cp -a "${WORKDIR_PATH}" "${SRC_DIR}"
echo
echo
echo "Removing pre-existing ${SRC_DIR}/dist..."
rm -rfv "${SRC_DIR}/dist"
echo
echo
echo "Building ${package_name} dist has been requested"
echo
echo
echo "Compile wheels"
for PYTHON in ${PYTHON_VERSIONS}; do
/opt/python/${PYTHON}/bin/python -m pip install -U pip
/opt/python/${PYTHON}/bin/python -m pip install -r "${WORKDIR_PATH}/requirements/wheel.txt"
PIP_CONSTRAINT="${WORKDIR_PATH}/requirements/cython.txt" \
/opt/python/${PYTHON}/bin/python -m pip wheel "${SRC_DIR}/" \
--config-settings=pure-python=false \
--no-deps \
-w "${ORIG_WHEEL_DIR}/${PYTHON}"
done
echo
echo
echo "Bundle external shared libraries into the wheels"
for whl in ${ORIG_WHEEL_DIR}/*/${package_name}-*-linux_${arch}.whl; do
echo "Repairing $whl..."
auditwheel repair "$whl" -w "${WHEELHOUSE_DIR}"
done
echo
echo
echo "Cleanup OS specific wheels"
rm -fv ${WHEELHOUSE_DIR}/*-linux_*.whl
echo
echo
echo "Cleanup non-$package_name wheels"
find "${WHEELHOUSE_DIR}" -maxdepth 1 -type f ! -name "$package_name"'-*-manylinux2010_*.whl' -print0 | xargs -0 rm -rf
echo
echo
echo "Install packages and test"
echo "dist directory:"
ls ${WHEELHOUSE_DIR}
for PYTHON in ${PYTHON_VERSIONS}; do
# clear python cache
find "${WORKDIR_PATH}" -type d -name __pycache__ -print0 | xargs -0 rm -rf
echo
echo -n "Test $PYTHON: "
/opt/python/${PYTHON}/bin/python -c "import platform; print('Building wheel for {platform} platform.'.format(platform=platform.platform()))"
/opt/python/${PYTHON}/bin/pip install -r ${WORKDIR_PATH}/requirements/ci-wheel.txt
/opt/python/${PYTHON}/bin/pip install "$package_name" --no-index -f "file://${WHEELHOUSE_DIR}"
/opt/python/${PYTHON}/bin/py.test ${WORKDIR_PATH}/tests
done
|