Skip to content

Instantly share code, notes, and snippets.

@candeira
Created August 9, 2021 23:00
Show Gist options
  • Save candeira/0be1f30eb53db42ffc0722e46ee5039e to your computer and use it in GitHub Desktop.
Save candeira/0be1f30eb53db42ffc0722e46ee5039e to your computer and use it in GitHub Desktop.
layout_poetry for direnv
# Layout Poetry originally from
# https://github.com/direnv/direnv/issues/592
layout_poetry() {
if [[ ! -f pyproject.toml ]]; then
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to cr
exit 2
fi
local VENV=$(poetry env list --full-path | cut -d' ' -f1)
if [[ -z $VENV || ! -d $VENV/bin ]]; then
log_error 'No poetry virtual environment found. Use `poetry install` to cre
exit 2
fi
export VIRTUAL_ENV=$VENV
export POETRY_ACTIVE=1
PATH_add "$VENV/bin"
}
gg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment