Dean Troyer | b1d8e8e | 2015-02-16 13:58:35 -0600 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # **tools/build_wheels.sh** - Build a cache of Python wheels |
| 4 | # |
| 5 | # build_wheels.sh [package [...]] |
| 6 | # |
| 7 | # System package prerequisites listed in files/*/devlibs will be installed |
| 8 | # |
| 9 | # Builds wheels for all virtual env requirements listed in |
| 10 | # ``venv-requirements.txt`` plus any supplied on the command line. |
| 11 | # |
| 12 | # Assumes ``tools/install_pip.sh`` has been run and a suitable pip/setuptools is available. |
| 13 | |
| 14 | # If TOP_DIR is set we're being sourced rather than running stand-alone |
| 15 | # or in a sub-shell |
| 16 | if [[ -z "$TOP_DIR" ]]; then |
| 17 | |
| 18 | set -o errexit |
| 19 | set -o nounset |
| 20 | |
| 21 | # Keep track of the devstack directory |
| 22 | TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
| 23 | FILES=$TOP_DIR/files |
| 24 | |
| 25 | # Import common functions |
| 26 | source $TOP_DIR/functions |
| 27 | |
| 28 | GetDistro |
| 29 | |
| 30 | source $TOP_DIR/stackrc |
| 31 | |
| 32 | trap err_trap ERR |
| 33 | |
| 34 | fi |
| 35 | |
| 36 | # Get additional packages to build |
| 37 | MORE_PACKAGES="$@" |
| 38 | |
Dean Troyer | b1d8e8e | 2015-02-16 13:58:35 -0600 | [diff] [blame] | 39 | # Exit on any errors so that errors don't compound |
| 40 | function err_trap { |
| 41 | local r=$? |
| 42 | set +o xtrace |
| 43 | |
| 44 | rm -rf $TMP_VENV_PATH |
| 45 | |
| 46 | exit $r |
| 47 | } |
| 48 | |
| 49 | # Get system prereqs |
| 50 | install_package $(get_packages devlibs) |
| 51 | |
| 52 | # Get a modern ``virtualenv`` |
| 53 | pip_install virtualenv |
| 54 | |
| 55 | # Prepare the workspace |
| 56 | TMP_VENV_PATH=$(mktemp -d tmp-venv-XXXX) |
| 57 | virtualenv $TMP_VENV_PATH |
| 58 | |
| 59 | # Install modern pip and wheel |
| 60 | $TMP_VENV_PATH/bin/pip install -U pip wheel |
| 61 | |
| 62 | # VENV_PACKAGES is a list of packages we want to pre-install |
| 63 | VENV_PACKAGE_FILE=$FILES/venv-requirements.txt |
| 64 | if [[ -r $VENV_PACKAGE_FILE ]]; then |
| 65 | VENV_PACKAGES=$(grep -v '^#' $VENV_PACKAGE_FILE) |
| 66 | fi |
| 67 | |
| 68 | for pkg in ${VENV_PACKAGES,/ } ${MORE_PACKAGES}; do |
| 69 | $TMP_VENV_PATH/bin/pip wheel $pkg |
| 70 | done |
| 71 | |
| 72 | # Clean up wheel workspace |
| 73 | rm -rf $TMP_VENV_PATH |