nix-config/modules/home/direnv/lib/python.sh
Bruno BELANYI 8a6af0e5b7
All checks were successful
ci/woodpecker/push/check Pipeline was successful
home: direnv: only mention 'poetry init'
`poetry new` creates a new directory, which isn't really what we're
interested in here.
2024-09-12 12:08:50 +00:00

26 lines
644 B
Bash

#shellcheck shell=bash
layout_poetry() {
if ! has poetry; then
# shellcheck disable=2016
log_error 'layout_poetry: `poetry` is not in PATH'
return 1
fi
if [[ ! -f pyproject.toml ]]; then
# shellcheck disable=2016
log_error 'layout_poetry: no pyproject.toml found. Use `poetry init` to create one first'
return 1
fi
# create venv if it doesn't exist
poetry run -q -- true
# shellcheck disable=2155
export VIRTUAL_ENV=$(poetry env info --path)
export POETRY_ACTIVE=1
PATH_add "$VIRTUAL_ENV/bin"
watch_file pyproject.toml
watch_file poetry.lock
}