[direnv] Add poetry layout command
This commit is contained in:
16
direnv/.config/direnv/direnvrc
Normal file
16
direnv/.config/direnv/direnvrc
Normal file
@ -0,0 +1,16 @@
|
||||
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=$(poetry env list --full-path | cut -d' ' -f1)
|
||||
if [[ -z $VENV || ! -d $VENV/bin ]]; then
|
||||
log_error 'No created poetry virtual environment found. Use `poetry install` to create one first.'
|
||||
exit 2
|
||||
fi
|
||||
VENV=$VENV/bin
|
||||
export VIRTUAL_ENV=$(echo "$VENV" | rev | cut -d'/' -f2- | rev)
|
||||
export POETRY_ACTIVE=1
|
||||
PATH_add "$VENV"
|
||||
}
|
||||
Reference in New Issue
Block a user