#!/bin/bash
#  virtualenv - Python virtualenv support

set -e


ve_dir() {
	local dir="${1:-.}"
	echo "$dir/.venv"
}

ve_activate_script() {
	local dir="${1:-.}"
	echo "$(ve_dir $dir)/bin/activate"
}

ve_activate() {
	if is_function deactivate; then
		debug "ve_activate: skipped"
		return
	fi

	# find activation script or create it
	local dir=${1:-.}
	local activate="$(ve_activate_script "$dir")"
	[ -f "$activate" ] || ve_create "$dir"

	# load the activation script in this shell
	debug "ve_activate: running \"$activate\""
	source "$activate"
}

ve_create() {
	local vdir
	vdir=$(ve_dir $1)
	if [ -d "$vdir" ]; then
		debug "ve_create: '$vdir' exists"
	else
		ve_update "$@"
	fi
}

ve_update() {
	run virtualenv "$(ve_dir $1)"
}

ve_delete() {
	local vdir
	vdir="$(ve_dir $1)"
	if [ -d "$vdir" ]; then
		run rm -r "$vdir"
	else
		debug "ve_delete: '$vdir' does not exist"
	fi
}

ve_install() {
	for i in "$@"; do
		run easy_install "$i"
	done
}

View the Developer Guide Index

View the Reference Manual Index


Generated on Wed Jun 28 07:40:25 PDT 2017 by mcsh d14 v0.20.0.