-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_setup_production.sh
83 lines (66 loc) · 1.73 KB
/
_setup_production.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
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
set -e
reset_color="\033[00m"
black="\033[30m"
red="\033[31m"
green="\033[32m"
yellow="\033[33m"
blue="\033[34m"
magenta="\033[35m"
cyan="\033[36m"
white="\033[37m"
if [[ -z $PYTHON ]]; then
PYTHON=python3
fi
clear
echo -e """${green}
==========================
Python Virtual Environment
==========================
${reset_color}"""
sleep 1
### Get rid of caches NOT in .venv
echo -e """${cyan}
Cleaning cached pyc files
${reset_color}"""
find . -type d ! -path './.venv/*' -name '__pycache__' -exec rm -rf {} +
find . -type d ! -path './.venv/*' -name '.pytest_cache' -exec rm -rf {} +
find . -type d ! -path './.venv/*' -name '.mypy_cache' -exec rm -rf {} +
### Check for existence of `.venv` dir
if [[ ! -d $PWD/.venv ]]; then
echo -e """${cyan}
Virtual environment not found -- Creating ".venv"
${reset_color}"""
$PYTHON -m venv .venv --prompt=sbn-survey-image-service
else
echo -e """${cyan}
Virtual environment found in ".venv"
${reset_color}"""
fi
### Activate VENV
source ./.venv/bin/activate
### Install package dependencies for project
echo -e """${green}
======================================
Setup ${white}production${green} dependencies and code
======================================
${reset_color}"""
pip install --upgrade -q -q -q pip setuptools wheel
latest=$(git describe --tags "$(git rev-list --tags --max-count=1)")
git checkout $latest
pip install .[recommended]
### Link git pre-commit-hook script
ln -fs $PWD/_precommit_hook $PWD/.git/hooks/pre-commit
if [ ! -f $PWD/.env ]; then
echo -e """${red}
To create a .env file:
source .venv/bin/activate
sbnsis env
Then edit .env
${reset_color}"""
fi
### 7. Final Message
echo -e """${cyan}
Done. Bon courage!
${reset_color}
"""