-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdirenvrc
More file actions
46 lines (37 loc) · 1.17 KB
/
direnvrc
File metadata and controls
46 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
layout_uv() {
if [[ ! -f pyproject.toml ]]; then
log_status 'No pyproject.toml found. Will initialize uv'
uv init --quiet
fi
VIRTUAL_ENV=$(dirname $(dirname $(uv run which python)))
PATH_add "$VIRTUAL_ENV/bin"
export UV_ACTIVE=1 # or VENV_ACTIVE=1
export VIRTUAL_ENV
}
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
PATH_add "$VIRTUAL_ENV/bin"
export VIRTUAL_ENV=$(poetry env info --path)
export POETRY_ACTIVE=1
}
layout_pdm() {
PYPROJECT_TOML="${PYPROJECT_TOML:-pyproject.toml}"
if [ ! -f "$PYPROJECT_TOML" ]; then
log_error 'No pyproject.toml found. Use `pdm init` to create one first.'
exit 2
fi
VIRTUAL_ENV=$(pdm venv list | grep "^\*" | awk -F" " '{print $3}')
if [ -z "$VIRTUAL_ENV" ] || [ ! -d "$VIRTUAL_ENV" ]; then
log_status "No virtual environment exists. Executing \`pdm info\` to create one."
pdm info
VIRTUAL_ENV=$(pdm venv list | grep "^\*" | awk -F" " '{print $3}')
fi
PATH_add "$VIRTUAL_ENV/bin"
export PDM_ACTIVE=1
export VIRTUAL_ENV
}