Skip to content

Instantly share code, notes, and snippets.

@richardkiss
Created March 18, 2021 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardkiss/cbc0b6fbc8518083812bfcdf7e11c4c7 to your computer and use it in GitHub Desktop.
Save richardkiss/cbc0b6fbc8518083812bfcdf7e11c4c7 to your computer and use it in GitHub Desktop.
A nice shell script to put all your venvs in the same place
#!/bin/sh
VENV_PATH=${@:-${VENV_BASE_PATH:-~/tmp/virtualenvs}}/`pwd | sed "s|/|_|g"`/venv
if [ -e $VENV_PATH ]
then
echo rm -rf $VENV_PATH
echo and try again
else
mkdir -p $VENV_PATH
echo building venv at $VENV_PATH
python3 -m venv $VENV_PATH
if [ -L activate ]
then
rm activate
fi
. $VENV_PATH/bin/activate
python -m pip install --upgrade pip
ln -s $VENV_PATH/bin/activate
echo now do \`source activate\`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment