Skip to content

Commit 21322a7

Browse files
authored
Merge pull request #763 from pytest-dev/add-envrc
Add `.envrc` that loads poetry virtualenv
2 parents 52e3cdf + ed1d581 commit 21322a7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

.envrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# config file for `direnv`: https://direnv.net
2+
# load the poetry virtual environment when entering the project directory
3+
4+
strict_env
5+
6+
if [[ ! -f "pyproject.toml" ]]; then
7+
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to create one first.'
8+
exit 2
9+
fi
10+
11+
local VENV="$(poetry env info --path)"
12+
if [[ -z $VENV || ! -d $VENV/bin ]]; then
13+
log_error 'No poetry virtual environment found. Use `poetry install` to create one first.'
14+
exit 2
15+
fi
16+
17+
source_env "$VENV/bin/activate"

0 commit comments

Comments
 (0)