blob: cfa39a82e0114749743e5a2121d2c777743fa2b0 [file] [log] [blame]
Dean Troyer8c2ce6e2015-02-18 14:47:54 -06001#!/usr/bin/env bash
2#
3# **tools/build_venv.sh** - Build a Python Virtual Envirnment
4#
5# build_venv.sh venv-path [package [...]]
6#
Dean Troyerdc97cb72015-03-28 08:20:50 -05007# Installs basic common prereq packages that require compilation
8# to allow quick copying of resulting venv as a baseline
9#
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060010# Assumes:
11# - a useful pip is installed
12# - virtualenv will be installed by pip
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060013
14
15VENV_DEST=${1:-.venv}
16shift
17
18MORE_PACKAGES="$@"
19
Dean Troyerdc97cb72015-03-28 08:20:50 -050020# If ``TOP_DIR`` is set we're being sourced rather than running stand-alone
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060021# or in a sub-shell
22if [[ -z "$TOP_DIR" ]]; then
23
24 set -o errexit
25 set -o nounset
26
Dean Troyerdc97cb72015-03-28 08:20:50 -050027 # Keep track of the DevStack directory
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060028 TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
29 FILES=$TOP_DIR/files
30
31 # Import common functions
32 source $TOP_DIR/functions
33
34 GetDistro
35
36 source $TOP_DIR/stackrc
37
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060038fi
39
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060040# Build new venv
41virtualenv $VENV_DEST
42
43# Install modern pip
Dean Troyer99c463d2015-02-19 13:05:15 -060044PIP_VIRTUAL_ENV=$VENV_DEST pip_install -U pip
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060045
Dean Troyer99c463d2015-02-19 13:05:15 -060046# Install additional packages
47PIP_VIRTUAL_ENV=$VENV_DEST pip_install ${MORE_PACKAGES}