Skip to content

Commit 160c24a

Browse files
committed
Use suggested snippet from direnv wiki
1 parent 2fed762 commit 160c24a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

.envrc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
export VIRTUAL_ENV=.venv
2-
layout python3
1+
# https://github.com/direnv/direnv/wiki/Python#uv
2+
layout_uv() {
3+
if [[ -d ".venv" ]]; then
4+
VIRTUAL_ENV="$(pwd)/.venv"
5+
fi
6+
7+
if [[ -z $VIRTUAL_ENV || ! -d $VIRTUAL_ENV ]]; then
8+
log_status "No virtual environment exists. Executing \`uv venv\` to create one."
9+
uv venv
10+
VIRTUAL_ENV="$(pwd)/.venv"
11+
fi
12+
13+
PATH_add "$VIRTUAL_ENV/bin"
14+
export UV_ACTIVE=1 # or VENV_ACTIVE=1
15+
export VIRTUAL_ENV
16+
}
17+
18+
layout_uv

0 commit comments

Comments
 (0)