For your virtual environment directory {ENV}
follow these steps
- Run
$ virtualenv --relocatable {ENV}
- Edit
{ENV}/bin/activate
, using vim or editor of your choice
- Edit
VIRTUAL_ENV
(around line ~42!)to match the new directory location
So if you are looking to write a script, you can either export VIRTUAL_ENV
shell variable or perform the edit on /bin/activate dynamically.
This is how I've setup mine.
# env/bin/activate
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# virtual env is at ./env
ENV_DIR=`dirname $BIN_DIR`
VIRTUAL_ENV=$ENV_DIR
export VIRTUAL_ENV