-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.sh
69 lines (51 loc) · 1.53 KB
/
run.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
#!/usr/bin/bash
# Python virtual environment
VENV_PATH="$(pwd)/venv"
# Pip virtual environment
PIPENV_PATH="$(pwd)/Pipfile.lock"
# List of dependencies
DEPENDENCIES_PATH="$(pwd)/requirements.txt"
install_dependencies() {
# Check if requirements.txt exists
if [ -f "$DEPENDENCIES_PATH" ]; then
pip install -r "$DEPENDENCIES_PATH"
else
pip install python-dotenv
pip install django django-ninja-extra
pip install firebase-admin psycopg2-binary
pip install pydantic[email]
pip freeze > requirements.txt
fi
}
run_server() {
echo "Running Server..."
python manage.py makemigrations v2
python manage.py migrate
python manage.py runserver
`$1`
}
if [ "$#" -eq 0 ] || [ "$1" = "venv" ]; then
echo "Activating virtual environment"
if [ ! -d "$VENV_PATH" ]; then
# Creating the python virtual environment
virtualenv "$VENV_PATH"
# Activating python virtual environment
source "$VENV_PATH/Scripts/activate"
# Installing the python dependencies
install_dependencies
else
# Activating python virtual environment
source "$VENV_PATH/Scripts/activate"
fi
# Running django local server
run_server deactivate
elif [ "$1" = "pipenv" ]; then
# Initializing pip virtual environment
pipenv shell
if [ ! -f "$PIPENV_PATH" ]; then
# Installing the python dependencies
install_dependencies pipenv
fi
# Running django local server
run_server exit
fi