generated from gdsc-upt/django-template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (66 loc) · 2.17 KB
/
Makefile
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
BASE_DIR := src
ACTIVATE_PATH := .venv/bin/activate
SHELL := /bin/bash
RUN := poetry run
MANAGE_PY := $(RUN) $(BASE_DIR)/manage.py
run: superuser
$(MANAGE_PY) runserver
migrations:
$(MANAGE_PY) makemigrations
migrate:
$(MANAGE_PY) migrate
lint:
$(RUN) black $(BASE_DIR)
$(RUN) pylint $(BASE_DIR)
$(RUN) pycodestyle --exclude=migrations --max-line-length=88 $(BASE_DIR)
$(RUN) mypy src
superuser:
$(MANAGE_PY) shell -c "import createsuperuser"
seed: config.yml
$(MANAGE_PY) shell -c "import random_seed"
test:
poetry run coverage run $(BASE_DIR)/manage.py test tests --noinput --timing
build:
docker-compose up --build
setup: config.yml
sudo apt install curl
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -
. $$HOME/.poetry/env
@echo "Create shell..."
poetry config virtualenvs.in-project true --local
poetry env use 3.9
@echo "Activating virtual environment..."
. $(ACTIVATE_PATH); \
echo "Installing requirements..."; \
poetry install; \
echo "Checking config.yml exists and has basic setup..."; \
python $(BASE_DIR)/manage.py shell -c "import check_config_vars"; \
echo "Setting up database..."; \
make migrate; \
echo "Ensuring admin user..."; \
make superuser; \
echo "Launching server..."; \
make run
setup-win: config.yml
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
call set PATH=%PATH%;%USERPROFILE%\.poetry\bin;
call set PATH=%USERPROFILE%\AppData\Local\Programs\Python\Python39;%PATH%;
call set PATH=%USERPROFILE%\AppData\Local\Programs\Python\Python39\Scripts;%PATH%;
echo Python system interpreter:
where python
python --version || goto :error
echo Checking variables configuration
pip install pyyaml
python src/check_config_vars.py || goto :error
echo Activating venv
call poetry shell
for /f %%p in ('poetry env info --path') do set POETRYPATH=%%p
call %POETRYPATH%\Scripts\activate.bat
echo Python version:
python -VV
echo installing requirements...
call poetry install || goto :error
echo Setting up database...
python src/manage.py migrate || goto :error
echo Ensuring admin user...
python src/manage.py shell -c "import createsuperuser"