-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate_venv
30 lines (27 loc) · 1.33 KB
/
activate_venv
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
# run by sourcing (need env for venv)
# source activate_venv
if type -p virtualenv > /dev/null 2>&1; then
if workon raptiformica > /dev/null 2>&1; then
# activate the existing virtual env
echo 'Virtualenv already configured for Raptiformica. It is now activated'
else
# set up the virtualen and install the base requirements
mkvirtualenv -a $(pwd) -p /usr/bin/python3 raptiformica
echo "PYTHONPATH=`pwd`" >> $VIRTUAL_ENV/bin/postactivate
pip3 install pip --upgrade
pip3 install -r requirements/base.txt
fi;
# create a symlink to the virtualenv if it does not exist or is not a
# symlink to the virtual env but something else (like a copied dir)
ls -ld .venv | grep -q $VIRTUAL_ENV || ln -fs $VIRTUAL_ENV .venv
# link helper tools to venv $PATH
ln -sf `pwd`/misc/snippets/testcase .venv/bin/
else
# No virtualenv on host system, trying to activate inherited virtualenv from
# the machine that slaved this machine. Will be overwritten with a link to the
# real venv once installed. If the system uses a different architecture or the
# venv does not work for some other reason, fall back to system python3 and
# hope for the best.
echo 'No virtualenv on this system, falling back to pre-synced .venv or system python'
source .venv/bin/activate || /bin/true
fi;