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()
{
# direnv-enabled venv creation.
if ! [[ -d .venv ]]
# direnv-first venv creation.
if [[ -f .envrc ]]
then
if [[ -f .envrc ]]
then
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
echo '`.envrc` file already exists!'
return
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()