Skip to content

Commit

Permalink
direnv: add layout uv
Browse files Browse the repository at this point in the history
  • Loading branch information
branchvincent committed Aug 17, 2024
1 parent d7f030e commit df89fe2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .config/direnv/direnvrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ layout_auto() {
elif [[ -f poetry.lock ]]; then
log_status "detected poetry project"
layout poetry
elif [[ -f uv.lock ]]; then
log_status "detected uv project"
layout uv
elif [[ -f pyproject.toml || -f setup.py ]]; then
log_status "detected python project"
layout python
Expand Down Expand Up @@ -69,7 +72,7 @@ layout_python() {
layout_poetry() {
# Install, if deps are outdated
if [[ ! -d .venv || poetry.lock -nt "$(echo .venv/lib/python*/site-packages)" ]]; then
uv venv -q
[ -d .venv ] || uv venv -q
poetry install
fi
watch_file poetry.lock
Expand All @@ -80,6 +83,19 @@ layout_poetry() {
PATH_add "$VIRTUAL_ENV/bin"
}

layout_uv() {
# Activate venv
export VIRTUAL_ENV="$PWD/.venv"
PATH_add "$VIRTUAL_ENV/bin"

# Install, if deps are outdated
if [[ ! -d .venv || uv.lock -nt "$(echo .venv/lib/python*/site-packages)" ]]; then
uv sync --frozen
touch .venv/lib/python*/site-packages
fi
watch_file uv.lock
}

### Pkgx ###

# Usage: parse_version <filename> <regex> [version]
Expand Down

0 comments on commit df89fe2

Please sign in to comment.