-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy path.envrc
44 lines (34 loc) · 1.1 KB
/
.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
35
36
37
38
39
40
41
42
43
44
set -e
# This uses a combination of direnv + pyenv to
# create and activate a virtual environment, and install
# development dependencies. Based on:
# https://hynek.me/til/python-project-local-venvs/
export VIRTUAL_ENV=.venv
PYTHON_VERSION="3.9.19"
# Check if .venv exists and the Python version matches
if [ -d ".venv" ]; then
CURRENT_VERSION=$(source .venv/bin/activate && python --version 2>&1 | cut -d' ' -f2)
if [ "$CURRENT_VERSION" != "$PYTHON_VERSION" ]; then
echo "Current Python version ($CURRENT_VERSION) does not match the desired version ($PYTHON_VERSION). Recreating .venv..."
rm -rf .venv
fi
fi
pyenv install --skip-existing "$PYTHON_VERSION"
layout pyenv "$PYTHON_VERSION"
python -m pip install -U pip
python -m pip install -q -r requirements.txt
# Load environment variables from the .env file (for pytest, mainly)
if [ ! -f .env ]; then
cp .env.example .env
fi
dotenv
# Install pre-commit hooks
pre-commit install
# Python
export PYTHONDONTWRITEBYTECODE=1
# UTF-8
export LC_ALL='en_US.UTF-8'
export LANG='en_US.UTF-8'
export LANGUAGE='en_US.UTF-8'
# Path
path_add PATH $(expand_path bin)