forked from danielfernau/unifi-protect-video-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.envrc
34 lines (29 loc) · 850 Bytes
/
.envrc
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
set -e
use_python() {
if [ -n "$(which pyenv)" ]; then
local pyversion=$1
eval "$(pyenv init -)"
pyenv local ${pyversion} || log_error "Could not find pyenv version '${pyversion}'. Consider running 'pyenv install ${pyversion}'"
fi
}
layout_poetry() {
if [[ -f backend/pyproject.toml ]]; then
local VENV=$( cd backend && poetry show -v|grep "Using virtualenv:"|cut -f 3 -d " " 2>/dev/null)
export VIRTUAL_ENV=$VENV
PATH_add "$VIRTUAL_ENV/bin"
fi
}
layout_virtualenv() {
if [ ! -d ".venv" ] ; then
echo "Installing virtualenv for $(python -V)"
python -m venv .venv
fi
echo "Activating $(python -V) virtualenv"
source .venv/bin/activate
}
# check if python version is set in current dir
pyversion=$(head .python-version)
pvenv=$(basename $PWD)
use python ${pyversion}
layout virtualenv
layout poetry