-
Notifications
You must be signed in to change notification settings - Fork 0
/
.envrc
36 lines (36 loc) · 1.32 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
# check if python version is set in current dir
if [ -f ".python-version" ] ; then
# ensure the python version is installed, if not, install it and configure
# for compatibility with `auto-pyvenv`
if [[ ! "$(pyenv versions | egrep $(cat .python-version))" ]] ; then
echo -n "Python version not found, installing "
echo "$(cat .python-version)"
pyenv install "$(cat .python-version)"
# rehash pyenv due to new install
pyenv rehash
# initial pyenv
eval "$(pyenv init -)"
echo "Upgrading pip to latest"
pyenv shell $(cat .python-version)
# upgrading setuptools in the event they are too old for `py2venv`
pip install --upgrade pip setuptools
if [ $(cat .python-version | egrep '^2.') ] ; then
# `py2venv` allows you to install a virtualenv with
# `python -m venv .venv`
echo "Python 2.x detected. Installing 'py2venv'"
pip install py2venv
fi
fi
fi
# if a .venv dir doesn't exist, create one based on the current activated
# python version
if [ ! -d ".venv" ] ; then
echo -n "Installing virtualenv for "
echo "$(python -V)"
python -m venv .venv
fi
# source the venv dir
echo -n "Activating virtualenv for "
echo "$(python -V)"
source .venv/bin/activate
echo "$(which python)"