home: direnv: add 'python' library file
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
19aabcf6f5
commit
d118351849
1 changed files with 25 additions and 0 deletions
25
home/direnv/lib/python.sh
Normal file
25
home/direnv/lib/python.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#shellcheck shell=bash
|
||||||
|
|
||||||
|
layout_poetry() {
|
||||||
|
if ! has poetry; then
|
||||||
|
# shellcheck disable=2016
|
||||||
|
log_error 'layout_poetry: `poetry` is not in PATH'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f pyproject.toml ]]; then
|
||||||
|
# shellcheck disable=2016
|
||||||
|
log_error 'layout_poetry: no pyproject.toml found. Use `poetry new` or `poetry init` to create one first'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create venv if it doesn't exist
|
||||||
|
poetry run true
|
||||||
|
|
||||||
|
# shellcheck disable=2155
|
||||||
|
export VIRTUAL_ENV=$(poetry env info --path)
|
||||||
|
export POETRY_ACTIVE=1
|
||||||
|
PATH_add "$VIRTUAL_ENV/bin"
|
||||||
|
watch_file pyproject.toml
|
||||||
|
watch_file poetry.lock
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue