forked from cfpb/consumerfinance.gov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate-virtualenv.sh
44 lines (37 loc) · 1.54 KB
/
activate-virtualenv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# ==========================================================================
# Script for activating the virtualenv (creating it first, if necessary).
# NOTE: Run this script while in the project root directory.
# It will not run correctly when run from another directory.
# DOCS: https://github.com/cfpb/development/blob/main/guides/installing-python.md
# ==========================================================================
# Confirm that variable VENV_NAME is already set to the name of the virtualenv
if [ -z $VENV_NAME ]; then
export VENV_NAME="consumerfinance.gov"
fi
echo 'Activating virtualenv, if not already activated...'
if ! type "workon" &>/dev/null; then
virtualenvwrapper_path=`which virtualenvwrapper.sh || echo 'not found'`
if [ "$virtualenvwrapper_path" == 'not found' ]; then
echo 'Error: virtualenvwrapper.sh is not on your path.' \
'Please ensure virtualenv & virtualenvwrapper are installed correctly.'
return
fi
echo "virtualenvwrapper found at $virtualenvwrapper_path"
source $virtualenvwrapper_path
fi
if ! which python3.6 &>/dev/null; then
echo 'Error: python3.6 is not in your path.' \
'Please ensure python3.6 is installed and available'
return
fi
if workon $VENV_NAME; then
echo "Virtualenv $VENV_NAME activated."
else
echo "Attempting to create new virtualenv $VENV_NAME..."
if mkvirtualenv -p `which python3.6` $VENV_NAME; then
echo "Virtualenv $VENV_NAME created and activated."
else
echo 'Error: virtualenv not activated.' \
'Something went wrong.'
fi
fi