Created
November 16, 2022 21:28
-
-
Save dcode/2b14d0d0d7d18829bbe436b116d1d6a5 to your computer and use it in GitHub Desktop.
direnv configuration to support `layout poetry`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.config/direnv/direnvrc | |
# Adapted from https://rgoswami.me/posts/poetry-direnv/ | |
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 | |
# create venv if it doesn't exist | |
poetry run true | |
export VIRTUAL_ENV=$(poetry env info --path) | |
export POETRY_ACTIVE=1 | |
PATH_add "$VIRTUAL_ENV/bin" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment