-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.envrc
29 lines (28 loc) · 1017 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
# check if python version is set in current dir
VIRTUAL_ENV="$PWD/venv"
if [ ! -d "$VIRTUAL_ENV" ]; then
PYTHON=python3
echo "Installing virtualenv for $($PYTHON -V)"
# if we didn't install `py2venv` for python 2.x, we would need to use
# `virtualenv`, which you would have to install separately.
$PYTHON -m venv "$VIRTUAL_ENV"
PYTHON="$VIRTUAL_ENV"/bin/python
PIP="$VIRTUAL_ENV"/bin/pip
$PIP install -q pip wheel -U
$PIP install -q pylint isort mypy black pre-commit
# install requirements.txt if exists
REQUIREMENTS=requirements.txt
if [ -f "$REQUIREMENTS" ]; then
echo "found requirements file, install it,"
$PIP install -r "$REQUIREMENTS"
fi
echo "Virtualenv has been activated for $($PYTHON -V)"
fi
if [ -d "$VIRTUAL_ENV" ]; then
# PS1 is not allowed to override in direnv env
# to avoid override by `activate`
export VIRTUAL_ENV_DISABLE_PROMPT=1
export VIRTUAL_ENV
PATH="${VIRTUAL_ENV}/bin:${PATH}"
export PATH
fi