-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.env
More file actions
executable file
·45 lines (40 loc) · 1.15 KB
/
.env
File metadata and controls
executable file
·45 lines (40 loc) · 1.15 KB
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
45
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
PYTHON=`which python3`
ROOT="$( command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BIN=$ROOT/bin
SRC=$ROOT/src
CONFIG=$ROOT/config
VENV_NAME=.venv
VENV=$ROOT/$VENV_NAME
# Create the actual virtualenv
if [ ! -d $VENV ]; then
read -r -p "Virtual environment \"$VENV\" not found. Would you like to create it? (recommended)? [y/n] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo "Creating virtual env..."
virtualenv -p python3 $VENV
fi
fi
# Add to path only if absent
echo $PYTHONPATH | grep -q $SRC \
|| export PYTHONPATH=$SRC:$PYTHONPATH
echo $PATH | grep -q $BIN \
|| export PATH=$BIN:$PATH
if [[ "$VIRTUAL_ENV" != "$VENV" ]]; then
echo "Switching to environment: $VENV"
which deactivate > /dev/null 2>&1 && deactivate
source $VENV/bin/activate
# Let us know what our env is
echo
echo
echo "PATH : $PATH"
echo "PYTHONPATH : $PYTHONPATH"
echo "PYTHONSTARTUP : $PYTHONSTARTUP"
echo "VIRTUAL_ENV : $VIRTUAL_ENV"
echo
echo "Virtualenv at $VENV"
echo "Python at `which python`"
echo "Pip at `which pip`"
echo
fi