Added poetry bit to direnv

This commit is contained in:
Alex Kelly 2021-06-18 17:04:25 -04:00
parent fdf1ffb04e
commit 656ae606db

View file

@ -7,3 +7,15 @@ layout_virtualenvwrapper() {
local venv_path="${WORKON_HOME}/$1" local venv_path="${WORKON_HOME}/$1"
layout_virtualenv $venv_path layout_virtualenv $venv_path
} }
layout_poetry() {
if [[ ! -f pyproject.toml ]]; then
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to create one first.'
exit 2
fi
local VENV=$(dirname $(poetry run which python))
export VIRTUAL_ENV=$(echo "$VENV" | rev | cut -d'/' -f2- | rev)
export POETRY_ACTIVE=1
PATH_add "$VENV"
}