Browse Source

Merge branch 'python3' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into python3

export_seznamu_prednasek
Anet 6 years ago
parent
commit
9c10149226
  1. 8
      .gitignore
  2. 100
      Makefile
  3. 2
      manage.py

8
.gitignore

@ -1,11 +1,5 @@
# virtual env # virtual env
/bin/ /env/
/include/
/lib/
/local/
/share/
/virtualenv/
/pip-selfcheck.json
# transient files # transient files
/db-test.sqlite3* /db-test.sqlite3*

100
Makefile

@ -1,68 +1,66 @@
.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 := python3
PYTHON=python3.4 VENV := python3 -m venv
VE_VER=16.0.0 # Všechny flagy, které se s venvem/virtualenvem/... mají volat patří sem. Volá se "${VENV} cesta"
LOCAL_PYTHON=bin/python VENV_PATH := env
# Musí být definovaná, i kdyby to měla být "."
all: install
.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
clean: clean_env
# 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)
veryclean: clean clean_virtualenv all:
@# Just echo:
install: virtualenv bin/python install_packages # Install je trochu magický:
# Spusť následující posloupnost příkazů:
# make install_venv
# phony, but depends on file # . ${VENV_PATH}/bin/activate
make_env: ${LOCAL_PYTHON} # make install_web
#
# phony, but fast repeated execution # Až skončíš s vývojem webu, spusť "deactivate". Tím zmizí '(${VENV_PATH})' ze začátku promptu.
install_packages: make_env
bin/pip install -r requirements.txt --upgrade venv_check:
@# Pokud org nemá zapnutý venv, poradíme mu, aby si ho zapnul a spadneme. Jinak nic.
# phony @expr $$PATH : ".*:*$(shell pwd)/${VENV_PATH}/bin" > /dev/null && exit 0 || echo 'Není zapnutý venv, spusť ". ${VENV_PATH}/bin/activate".\nPokud není venv nainstalovaný, spusť "make install_venv"' && false
clean_env:
rm -rf bin/ include/ lib/ local/ share/ clean: clean_venv clean_schema
install: install_web
install_web: venv_check
@# venv může být příšerně starý, takže nejdříve upgradujeme venvové věci
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 rm -f pip-selfcheck.json
clean_schema:
rm -f schema_seminar.pdf schema_all.pdf rm -f schema_seminar.pdf schema_all.pdf
# binary name representing set-up env run: venv_check
${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:
./manage.py runserver ./manage.py runserver
test: test: venv_check
./manage.py test -v2 seminar mamweb ./manage.py test -v2 seminar mamweb
# DB schemata # DB schemata
schema: schema_seminar.pdf schema_all.pdf 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 ./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 ./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
# Deploy to current *mamweb-test* directory # 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 [ ${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 @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 ..." @echo "Installing version from origin/test ..."
@ -78,7 +76,7 @@ deploy_test:
@echo Done. @echo Done.
# Deploy to current *mamweb-prod* directory # 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 [ ${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 @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 ..." @echo "Backing up production DB ..."
@ -128,4 +126,4 @@ sync_local_db:
pg_restore -c -d mam-prod last.pgdump pg_restore -c -d mam-prod last.pgdump
# Sync database and media. See above lines # 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 os
import sys import sys

Loading…
Cancel
Save