Browse Source

Nový Makefile. Bude vyžadovat změny uWSGi configu.

export_seznamu_prednasek
Mee 6 years ago
parent
commit
48655b4d5a
  1. 2
      .gitignore
  2. 93
      Makefile
  3. 2
      manage.py

2
.gitignore

@ -1,4 +1,6 @@
# virtual env
/env/
/bin/
/include/
/lib/

93
Makefile

@ -1,68 +1,65 @@
.PHONY: clean_env init_env clean_virtualenv install_packages clean install run all schema_seminar.pdf schema_all.pdf sync_test_media sync_test_db sync_test sync_local_media sync_local_db sync_local
PYTHON=python2.7
VE_VER=16.0.0
LOCAL_PYTHON=bin/python
PYTHON := python3
VENV := python3 -m venv
# Všechny flagy, které se s venvem/virtualenvem/... mají volat patří sem. Volá se "${VENV} cesta"
VENV_PATH := env
# Musí být definovaná, i kdyby to měla být "."
all: install
clean: clean_env
veryclean: clean clean_virtualenv
install: virtualenv bin/python install_packages
# phony, but depends on file
make_env: ${LOCAL_PYTHON}
.PHONY: all venv_check clean install install_web install_venv clean_venv clean_schema run test deploy_test deploy_prod sync_test_media sync_test_db sync_test sync_local_media sync_local_db sync_local
# phony, but fast repeated execution
install_packages: make_env
bin/pip install -r requirements.txt --upgrade
# activate by mělo být předpokladem ke všemu, co volá webový python (i.e. python nasazený do ${VENV}u kvůli webu, např. manage.py)
all: install
# phony
clean_env:
rm -rf bin/ include/ lib/ local/ share/
venv_check:
@# Pokud org nemá zapnutý venv, poradíme mu, aby si ho zapnul a spadneme. Jinak nic.
@expr $$PATH : ".*:*$(shell pwd)/${VENV_PATH}/bin" > /dev/null && exit 0 || echo "Není zapnutý env, spusť \". ${VENV_PATH}/bin/activate\"." && false
clean: clean_venv clean_schema
install:
@# Just echo:
# Install je trochu magický:
# Spusť následující posloupnost příkazů:
# make install_venv
# . ${VENV_PATH}/bin/activate
# make install_web
install_web: venv_check
@# venv může být příšerně starý, takže nejdříve upgradujeme venvové věci
echo $$PATH
pip install --upgrade pip
pip install --upgrade setuptools
# Instalace závislostí webu
pip install -r requirements.txt --upgrade
install_venv:
${VENV} ${VENV_PATH}
clean_venv:
# Možná není 100% foolproof...
@test ! ${VENV_PATH} = . || ! echo "Smaž si prosím venv sám, nebudu mazat celý web"
rm -rfv ${VENV_PATH}
rm -f pip-selfcheck.json
clean_schema:
rm -f schema_seminar.pdf schema_all.pdf
# binary name representing set-up env
${LOCAL_PYTHON}: virtualenv
${PYTHON} virtualenv/virtualenv.py .
# directory name
virtualenv:
# I could not find a link without hash anymore. This will probably break in
# the future.
curl -O https://files.pythonhosted.org/packages/33/bc/fa0b5347139cd9564f0d44ebd2b147ac97c36b2403943dbee8a25fd74012/virtualenv-16.0.0.tar.gz
tar xvfz virtualenv-${VE_VER}.tar.gz
mv -T virtualenv-${VE_VER} virtualenv
rm virtualenv-${VE_VER}.tar.gz
# phony
clean_virtualenv:
rm -rf virtualenv/
rm -rf virtualenv-*.tar.gz
run:
run: venv_check
./manage.py runserver
test:
test: venv_check
./manage.py test -v2 seminar mamweb
# DB schemata
schema: schema_seminar.pdf schema_all.pdf
schema_seminar.pdf:
schema_seminar.pdf: venv_check
./manage.py graph_models seminar | dot -Tpdf > schema_seminar.pdf
schema_all.pdf:
schema_all.pdf: venv_check
./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
# Deploy to current *mamweb-test* directory
deploy_test:
deploy_test: venv_check
@if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi
@if [ `pwd` != "/akce/mam/www/mamweb-test" ]; then echo "Only possible in /akce/mam/www/mamweb-test"; exit 1; fi
@echo "Installing version from origin/test ..."
@ -78,7 +75,7 @@ deploy_test:
@echo Done.
# Deploy to current *mamweb-prod* directory
deploy_prod:
deploy_prod: venv_check
@if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi
@if [ `pwd` != "/akce/mam/www/mamweb-prod" ]; then echo "Only possible in /akce/mam/www/mamweb-prod"; exit 1; fi
@echo "Backing up production DB ..."
@ -128,4 +125,4 @@ sync_local_db:
pg_restore -c -d mam-prod last.pgdump
# Sync database and media. See above lines
sync_local: sync_media sync_db
sync_local: sync_local_media sync_local_db

2
manage.py

@ -1,4 +1,4 @@
#!bin/python
#!/usr/bin/env python
import os
import sys

Loading…
Cancel
Save