Created
April 12, 2019 20:45
-
-
Save maxbrunet/6120b14c2229c95d440f14611efa2391 to your computer and use it in GitHub Desktop.
Script to migrate from virtualenvwrapper to pyenv-virtualenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
PYTHON_EXE='python3' | |
VIRTUALENVWRAPPER='virtualenvwrapper.sh' | |
echo '>>> Sourcing virtualenvwrapper...' | |
. "${VIRTUALENVWRAPPER}" | |
echo '>>> Starting migration from virtualenvwrapper to pyenv-virtualenv...' | |
VIRTUALENVS=$(lsvirtualenv -b) | |
for venv in ${VIRTUALENVS}; do | |
printf '>>> Migrating %s...\n' "${venv}" | |
printf '>>> Creating pyenv-virtualenv for %s...\n' "${venv}" | |
pyenv virtualenv --python="${PYTHON_EXE}" "${venv}" | |
printf '>>> Reinstalling packages in new pyenv-virtualenv from %s/%s...\n' "${WORKON_HOME}" "${venv}" | |
"${WORKON_HOME}/${venv}/bin/pip" freeze \ | |
| PYENV_VERSION="${venv}" pyenv exec pip install -r /dev/stdin | |
printf '>>> %s: Done' "${venv}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment