devstack/tools/build_wheels.sh
Dean Troyer b1d8e8e274 Build wheel cache for venvs
Building a bunch of virtual envs later is going to be tedious if we do not
pre-cache certain annoying-to-build packages.

* tools/build_wheels.sh: pre-build some wheels for annoying package installs
* list distro package dependencies in files/*/venv
* list packages to pre-build as wheels in files/venv-requirements.txt
* install database Python modules when setting up the database

Change-Id: Idff1ea69a5ca12ba56098e664dbf6924fe6a2e47
2015-02-18 15:13:00 -06:00

78 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# **tools/build_wheels.sh** - Build a cache of Python wheels
#
# build_wheels.sh [package [...]]
#
# System package prerequisites listed in files/*/devlibs will be installed
#
# Builds wheels for all virtual env requirements listed in
# ``venv-requirements.txt`` plus any supplied on the command line.
#
# Assumes ``tools/install_pip.sh`` has been run and a suitable pip/setuptools is available.
# If TOP_DIR is set we're being sourced rather than running stand-alone
# or in a sub-shell
if [[ -z "$TOP_DIR" ]]; then
set -o errexit
set -o nounset
# Keep track of the devstack directory
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
FILES=$TOP_DIR/files
# Import common functions
source $TOP_DIR/functions
GetDistro
source $TOP_DIR/stackrc
trap err_trap ERR
fi
# Get additional packages to build
MORE_PACKAGES="$@"
# Set a fall-back default, assume that since this script is being called
# package builds are to happen even if WHEELHOUSE is not configured
export WHEELHOUSE=${WHEELHOUSE:-.wheelhouse}
# Exit on any errors so that errors don't compound
function err_trap {
local r=$?
set +o xtrace
rm -rf $TMP_VENV_PATH
exit $r
}
# Get system prereqs
install_package $(get_packages devlibs)
# Get a modern ``virtualenv``
pip_install virtualenv
# Prepare the workspace
TMP_VENV_PATH=$(mktemp -d tmp-venv-XXXX)
virtualenv $TMP_VENV_PATH
# Install modern pip and wheel
$TMP_VENV_PATH/bin/pip install -U pip wheel
# VENV_PACKAGES is a list of packages we want to pre-install
VENV_PACKAGE_FILE=$FILES/venv-requirements.txt
if [[ -r $VENV_PACKAGE_FILE ]]; then
VENV_PACKAGES=$(grep -v '^#' $VENV_PACKAGE_FILE)
fi
for pkg in ${VENV_PACKAGES,/ } ${MORE_PACKAGES}; do
$TMP_VENV_PATH/bin/pip wheel $pkg
done
# Clean up wheel workspace
rm -rf $TMP_VENV_PATH