blob: 11d1d352084f6977cc38bbf58efca586df696308 [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#
7# Assumes:
8# - a useful pip is installed
9# - virtualenv will be installed by pip
10# - installs basic common prereq packages that require compilation
11# to allow quick copying of resulting venv as a baseline
12
13
14VENV_DEST=${1:-.venv}
15shift
16
17MORE_PACKAGES="$@"
18
19# If TOP_DIR is set we're being sourced rather than running stand-alone
20# or in a sub-shell
21if [[ -z "$TOP_DIR" ]]; then
22
23 set -o errexit
24 set -o nounset
25
26 # Keep track of the devstack directory
27 TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
28 FILES=$TOP_DIR/files
29
30 # Import common functions
31 source $TOP_DIR/functions
32
33 GetDistro
34
35 source $TOP_DIR/stackrc
36
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060037fi
38
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060039# Build new venv
40virtualenv $VENV_DEST
41
42# Install modern pip
Dean Troyer99c463d2015-02-19 13:05:15 -060043PIP_VIRTUAL_ENV=$VENV_DEST pip_install -U pip
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060044
Dean Troyer99c463d2015-02-19 13:05:15 -060045# Install additional packages
46PIP_VIRTUAL_ENV=$VENV_DEST pip_install ${MORE_PACKAGES}