| Dean Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 1 | #!/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 Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 7 | # Installs basic common prereq packages that require compilation | 
|  | 8 | # to allow quick copying of resulting venv as a baseline | 
|  | 9 | # | 
| Dean Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 10 | # Assumes: | 
|  | 11 | # - a useful pip is installed | 
|  | 12 | # - virtualenv will be installed by pip | 
| Dean Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 13 |  | 
|  | 14 |  | 
|  | 15 | VENV_DEST=${1:-.venv} | 
|  | 16 | shift | 
|  | 17 |  | 
|  | 18 | MORE_PACKAGES="$@" | 
|  | 19 |  | 
| Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 20 | # If ``TOP_DIR`` is set we're being sourced rather than running stand-alone | 
| Dean Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 21 | # or in a sub-shell | 
|  | 22 | if [[ -z "$TOP_DIR" ]]; then | 
|  | 23 |  | 
|  | 24 | set -o errexit | 
|  | 25 | set -o nounset | 
|  | 26 |  | 
| Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 27 | # Keep track of the DevStack directory | 
| Dean Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 28 | 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 Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 38 | fi | 
|  | 39 |  | 
| Dean Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 40 | # Build new venv | 
|  | 41 | virtualenv $VENV_DEST | 
|  | 42 |  | 
|  | 43 | # Install modern pip | 
| Dean Troyer | 99c463d | 2015-02-19 13:05:15 -0600 | [diff] [blame] | 44 | PIP_VIRTUAL_ENV=$VENV_DEST pip_install -U pip | 
| Dean Troyer | 8c2ce6e | 2015-02-18 14:47:54 -0600 | [diff] [blame] | 45 |  | 
| Dean Troyer | 99c463d | 2015-02-19 13:05:15 -0600 | [diff] [blame] | 46 | # Install additional packages | 
|  | 47 | PIP_VIRTUAL_ENV=$VENV_DEST pip_install ${MORE_PACKAGES} |