-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.sh
executable file
·70 lines (54 loc) · 1.89 KB
/
setup.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
python_version=3.7.6
set -e
script_dir=$(dirname $0)
if [ $script_dir = '.' ]
then
script_dir="$(pwd)"
fi
pushd $script_dir > /dev/null
# Prerequisite: Make sure that we have pyenv installed. If not, then exit.
echo "Ensuring that pyenv is installed..."
command -v pyenv >/dev/null 2>&1 || {
echo >&2 "Error: pyenv does not appear to be installed."
echo >&2 " Please follow the installation instructions here before running this script:"
echo >&2 " https://github.com/pyenv/pyenv#installation"
exit 1
}
echo "Done."
# Use pyenv to install the prescribed version of Python.
echo "Using pyenv to install the prescribed version of Python ($python_version)..."
pyenv install $python_version --skip-existing >/dev/null 2>&1 || {
echo >&2 "Error: Unable to install Python version $(cat .python-version) using pyenv.";
echo >&2 " Try updating pyenv by running: ";
echo >&2 " ";
echo >&2 " brew update && brew upgrade pyenv"
exit 1
}
echo "Done."
pyenv local $python_version
# Create a virtual environment for this project.
virtualenv_name=venv-$(basename $script_dir)
echo "Creating a virtual environment for this project called $virtualenv_name..."
mkdir -p .$virtualenv_name/
python -m venv .$virtualenv_name
echo "Done."
# Activate the virtual environment
echo "Activating the virtual environment..."
source .$virtualenv_name/bin/activate
echo "Done."
echo "Upgrading pip..."
pip install --upgrade pip
echo "Done."
echo "Installing requirements.txt..."
pip install -U -r requirements.txt
echo "Done."
echo "Installing dev-requirements.txt..."
pip install -U -r requirements-dev.txt
echo "Done."
echo "
Setup succeeded!
- Now run 'source .$virtualenv_name/bin/activate' in the shell to activate the
virtual environment.
- Run 'deactivate' to exit the virtual environment."
popd > /dev/null