direnv-first venv creation.

This commit is contained in:
Julien Palard 2023-01-20 13:48:24 +01:00
parent 799ab218ad
commit c174ac7e17
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
1 changed files with 12 additions and 10 deletions

22
.bashrc
View File

@ -175,18 +175,20 @@ e()
venv() venv()
{ {
# direnv-enabled venv creation. # direnv-first venv creation.
if ! [[ -d .venv ]] if [[ -f .envrc ]]
then then
if [[ -f .envrc ]] echo '`.envrc` file already exists!'
then return
echo '`.venv` does not exists but `.envrc` file already exists!'
echo "Human? Untangle it, please."
return
fi
"python$1" -m venv .venv
echo 'PATH=$(pwd)/.venv/bin/:$PATH' > .envrc
fi fi
cat >.envrc <<EOF
if ! [[ -d .venv ]]; then
echo "Creating venv..."
python$1 -m venv .venv
fi
PATH=$(pwd)/.venv/bin/:$PATH
EOF
direnv allow .
} }
pip-common() pip-common()