Skip to content

Instantly share code, notes, and snippets.

@slobber
Created October 12, 2017 02:46
Show Gist options
  • Save slobber/36735dfd8e89a870b7542f3d47fc77bc to your computer and use it in GitHub Desktop.
Save slobber/36735dfd8e89a870b7542f3d47fc77bc to your computer and use it in GitHub Desktop.
move_virtualenv
VIRTUALENV_NAME=py2.ipy5
PYENV=`grep -oP '(?<=VIRTUAL_ENV=")(.*)(?=")' ${VIRTUALENV_NAME}/bin/activate`
PWD=`pwd`
if [ $PYENV != "${PWD}/${VIRTUALENV_NAME}" ]; then
echo "First run, prepare environment..."
source "${PWD}/${VIRTUALENV_NAME}/bin/activate"
pip freeze > requirements.txt
deactivate
rm -rf "${PWD}/${VIRTUALENV_NAME}"
virtualenv "${PWD}/${VIRTUALENV_NAME}"
source "${PWD}/${VIRTUALENV_NAME}/bin/activate"
pip install -r requirements.txt
rm -f requirements.txt
deactivate
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment