From 656ae606db8521158b1c3628309242dd203a3fe2 Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Fri, 18 Jun 2021 17:04:25 -0400 Subject: [PATCH] Added poetry bit to direnv --- dot_direnvrc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dot_direnvrc b/dot_direnvrc index 4abe70d..609a09a 100644 --- a/dot_direnvrc +++ b/dot_direnvrc @@ -7,3 +7,15 @@ layout_virtualenvwrapper() { local venv_path="${WORKON_HOME}/$1" 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" +}