1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-06-18 06:48:33 +02:00
dotfiles/functions/python.zsh
bretello 5f4b4538bb
zsh: functions: mkvenv: replace venv with virtualenv
virtualenv is faster than venv and also installs wheel by default
2022-06-21 23:05:35 +02:00

25 lines
855 B
Bash

mkvenv(){
local source_venv
if [[ $1 == "-s" ]]; then
source_venv=y
shift
fi
# any arguments are passed on to the `venv` module as flags/arguments
if [[ -e .venv ]]; then
echo "$(color $RED Error:) $(color $BOLD .venv) already exists." >&2
return 1
fi
echo -n "Creating venv..." && python -m virtualenv $@ .venv || echo -e "Failed to create virtualenv. Is virtualenv installed? Try:\n $ pip install virtualenv"
if [[ -z ${source_venv} ]]; then
echo -n " done. Enable? [Y/n]"
read source_venv
else
echo ""
fi
if [[ $source_venv != "n" ]]; then
source .venv/bin/activate && echo -e "$(color $BOLD Enabled!) 🐍 $(color $BOLD$PURPLE $(python --version | cut -d " " -f2 )) ($(color $BOLD$GREEN $(pip --version | cut -d " " -f -2)))"
fi
}