-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython3-venv.sh
executable file
·34 lines (26 loc) · 973 Bytes
/
python3-venv.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
#!/bin/bash -e
ROOT=$(git rev-parse --show-toplevel)
help() {
cat <<EOF
Usage: ./$(basename $0)
Prerequisites: The python3-venv package has to be installed. Run "sudo apt install python3-venv -y" to do so (on debian like distros).
Description:
This script creates a virtual environment for python3 at "$ROOT/.venv" and installs all pip packages
from the "$ROOT/requirements.txt" file in it.
Options:
-h, --help Show this help message and exit.
EOF
}
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
help
exit 0
fi
if !python3 -m venv --help > /dev/null 2>&1; then
echo -e "🚨 ERROR: Cannot perform "python3 -m venv --help". Is the python3-venv package installed? \n"
help
exit 1
fi
python3 -m venv $ROOT/.venv && source $ROOT/.venv/bin/activate
pip install --upgrade --quiet pip setuptools wheel
pip install --upgrade --quiet --requirement "$ROOT/requirements.txt"
echo -e "✅ Successfully installed pip packages:\n$(pip freeze)"