Skip to content

Commit

Permalink
Add .envrc that loads poetry env
Browse files Browse the repository at this point in the history
  • Loading branch information
youtux committed Jan 11, 2025
1 parent 8180cc7 commit d1520bf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# config file for `direnv`: https://direnv.net
# load the poetry virtual environment when entering the project directory

strict_env

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 info --path)"
if [[ -z $VENV || ! -d $VENV/bin ]]; then
log_error 'No poetry virtual environment found. Use `poetry install` to create one first.'
exit 2
fi

source_env "$VENV/bin/activate"

0 comments on commit d1520bf

Please sign in to comment.