Skip to content

Instantly share code, notes, and snippets.

@danielk333
Last active September 9, 2022 08:59
Show Gist options
  • Save danielk333/588c1b9b07cdfefc8d7af7f2d885a051 to your computer and use it in GitHub Desktop.
Save danielk333/588c1b9b07cdfefc8d7af7f2d885a051 to your computer and use it in GitHub Desktop.
HPC-venvs
activate () {
source ~/projects/$1/.venv/bin/activate
}
venv () {
if [ -z $1 ]
then
echo "No project name given, exiting"
return
fi
target_venv=~/projects/$1/.venv
if [ ! -d "~/projects/$1" ]
then
echo "Project does not exist, exiting"
return
fi
echo "New venv target=$target_venv"
if [ -d "$target_venv" ]
then
echo "Folder '$1' already has a virtual enviornment, exiting"
else
python -m venv --upgrade-deps --system-site-packages $target_venv
echo "Created virtualenv $venv_target"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment