This repository was archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (83 loc) · 4.25 KB
/
Copy pathMakefile
File metadata and controls
104 lines (83 loc) · 4.25 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
VENV := . .venv/bin/activate &&
PYTHON := python3
PYENV_PYTHON_VERSION := 3.9.18
#PYTHON_VERSION_MIN := 3.9
#PYTHON_VERSION_CUR := $(shell $(PYTHON) -c 'import sys; print("%d.%d"% sys.version_info[0:2])' )
PYTHON_VERSION_OK := $(shell $(PYTHON) -c 'import sys; print(sys.version_info[0] == 3 and sys.version_info[1] >= 9)' )
POFILES := apps/api/locale/de/LC_MESSAGES/django.po apps/administrator/locale/de/LC_MESSAGES/django.po apps/core/locale/de/LC_MESSAGES/django.po apps/customer/locale/de/LC_MESSAGES/django.po locale/de/LC_MESSAGES/django.po
SHELL := /bin/bash
all:
@echo "help:"
@echo " make quickstart_debian"
@echo " make quickstart_fedora"
@echo " make runserver"
@echo " make clean"
clean:
rm -Rf .venv
rm -f db.sqlite3
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
install:
if [ -f /etc/lsb-release ]; then make quickstart_debian; else make quickstart_fedora; fi
quickstart_debian: debian_packages quickstart
debian_packages:
(dpkg -l | grep python3-dev) || (sudo apt update && sudo apt install python3-venv python3-dev python3-pip gettext -y)
quickstart_fedora: fedora_packages quickstart
fedora_packages:
(rpm -qa | grep python3-devel) || sudo dnf install python3-devel python3-pip
quickstart_without_demodb: create_venv pip_packages create_db create_superuser
@echo
@echo =====================================================================================
@echo Installation has finished successfully
@echo Run '"'make runserver'"' in order to start the server and access it through one of the following IP addresses
@ip addr | sed 's/\/[0-9]*//' | awk '/inet / {print "http://" $$2 ":8000/"}'
@echo For the first login, the user is '"'admin'"', and the password is '"'admin'"'
quickstart: quickstart_without_demodb demo_db
create_superuser:
${VENV} echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.filter(is_superuser=True).exists() or User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python manage.py shell
pip_packages:
source ~/.profile && $(PYTHON) -m pipenv install
create_venv:
ifeq ($(PYTHON_VERSION_OK),False)
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$$HOME/.pyenv"' >> ~/.profile
echo 'command -v pyenv >/dev/null || export PATH="$$PYENV_ROOT/bin:$$PATH"' >> ~/.profile
echo 'eval "$$(pyenv init -)"' >> ~/.profile
source ~/.profile && pyenv install ${PYENV_PYTHON_VERSION}
source ~/.profile && pyenv global ${PYENV_PYTHON_VERSION}
source ~/.profile && python3 -m pip install --user --upgrade pip pipenv
echo 'export PIPENV_VENV_IN_PROJECT=1' >> ~/.profile
source ~/.profile && $(PYTHON) -m pipenv install --python ${PYENV_PYTHON_VERSION}
else
echo 'export PIPENV_VENV_IN_PROJECT=1' >> ~/.profile
python3 -m pipenv --version || python3 -m pip install pipenv
source ~/.profile && python3 -m pipenv install
endif
create_db:
if [ ! -f saasadmin/settings_local.py ]; then cp saasadmin/settings_local.py.example saasadmin/settings_local.py; fi
${VENV} python manage.py migrate
${VENV} python manage.py compilemessages
collectstatic:
${VENV} (echo "yes" | python manage.py collectstatic)
runserver: collectstatic
${VENV} python manage.py runserver localhost:8000
token:
${VENV} python manage.py drf_create_token -r admin
demo_db:
${VENV} cat demodata/insertdemo.sql | python manage.py dbshell
(${VENV} cat demodata/insertdemo.psql.sql | python manage.py dbshell) || echo "ignore errors for sqlite"
translate:
#${VENV} django-admin compilemessages
${VENV} cd apps/api && django-admin compilemessages || exit -1
${VENV} cd apps/administrator && django-admin compilemessages || exit -1
${VENV} cd apps/core && django-admin compilemessages || exit -1
${VENV} cd apps/customer && django-admin compilemessages || exit -1
messages:
${VENV} django-admin makemessages -l de || exit -1
# drop "POT Creation Date" as long as this fix has not arrived yet: https://github.com/django/django/commit/4bfe8c0eec835b8eaffcda7dc1e3b203751a790a
for f in ${POFILES}; do sed -i '/POT-Creation-Date/d' $$f; done
${VENV} django-admin compilemessages || exit -1
update:
git pull || exit -1
${VENV} python manage.py migrate || exit -1
${VENV} django-admin compilemessages || exit -1
${VENV} (echo "yes" | python manage.py collectstatic) || exit -1