/ pyramid / GMI_Pyramid /
/pyramid/GMI_Pyramid/Makefile
1 # Copyright (C) 2013 The Meme Factory, Inc. http://www.meme.com/
2 #
3 # This file is part of Gombe-MI.
4 #
5 # Gombe-MI is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Gombe-MI. If not, see <http://www.gnu.org/licenses/>.
17 #
18 # Karl O. Pinc <kop@meme.com>
19 #
20 # Makefile for pyramid app setup and maintenance.
21 #
22 # See the INSTALL file for initial setup that must be done by root.
23 #
24 # See: http://www.pylonsproject.org/
25
26 PYRAMID_VERSION := 1.5
27 MODWSGI_VENV := /usr/local/lib/pyramid_env
28 DEVEL_VENV := ../devel_venv
29
30 PROJECT_NAME := GMI_Pyramid
31 DEVEL_STUFF := $(PROJECT_NAME).egg-info distribute-0.6.10.tar.gz dist build \
32 $(PROJECT_NAME).egg
33
34 .PHONY: help
35 help:
36 @echo 'Targets are:'
37 @echo ' help This help'
38 @echo ' modwsgi_venv Create python virtual env into which live'
39 @echo ' app is installed and run with'
40 @echo ' Apache mod_wsgi.'
41 @echo ' ../devel_venv Create local virtual env into which devel'
42 @echo ' app is installed and run.'
43 @echo ' install_prod Install production app into modwsgi_venv.'
44 @echo ' configure_prod Install production.ini into modwsgi_venv.'
45 @echo ' install_devel Install development app into devel_venv.'
46 @echo ' run_devel Run the app in development mode.'
47 @echo ' test_devel Run unit tests in the development venv.'
48 @echo ' clean_devel_venv Destroy devel_venv.'
49 @echo ' clean_prod Destroy modwsgi_venv.'
50 @echo ' clean Destroy all generated development files.'
51 @echo ' maintainerclean Start development entirely over.'
52 @echo
53 @echo 'Production related changes must be made through this Makefile'
54 @echo 'or with a umask of 0002 to support collaboration with gombemi'
55 @echo 'Unix group members.'
56
57 # Note that we'd like to make modwsgi_venv depend on $(MODWSGI_VENV) and
58 # have the work done there. This way other production targets could also
59 # depend on $(MODWSGI_VENV). But the directory itself must be made by root.
60
61 .PHONY: modwsgi_venv
62 modwsgi_venv:
63 # Allow UPG collaboration.
64 umask 0002 ; \
65 virtualenv --no-site-packages $(MODWSGI_VENV) ; \
66 $(MODWSGI_VENV)/bin/easy_install "pyramid==$(PYRAMID_VERSION)" ; \
67 printf '%s\n%s\n%s\n%s\n' \
68 'from pyramid.paster import get_app, setup_logging' \
69 "ini_path = '$(MODWSGI_VENV)/production.ini'" \
70 'setup_logging(ini_path)' \
71 "application = get_app(ini_path, 'main')" \
72 > $(MODWSGI_VENV)/pyramid.wsgi
73
74 .PHONY: make_egg
75 make_egg:
76 rm -rf dist
77 $(MODWSGI_VENV)/bin/python setup.py bdist_egg
78 ln -sf dist/$(PROJECT_NAME)*.egg $(PROJECT_NAME).egg
79
80 .PHONY: install_prod
81 install_prod: make_egg
82 umask 0002 ; \
83 $(MODWSGI_VENV)/bin/easy_install $$(readlink $(PROJECT_NAME).egg)
84
85 .PHONY: configure_prod
86 configure_prod:
87 umask 0002 ; \
88 cp production.ini $(MODWSGI_VENV)
89
90 $(DEVEL_VENV):
91 # Create venv
92 virtualenv --no-site-packages $(DEVEL_VENV)
93 # Install pyramid
94 $(DEVEL_VENV)/bin/easy_install "pyramid==$(PYRAMID_VERSION)"
95
96 .PHONY: install_devel
97 install_devel: $(DEVEL_VENV)
98 $(DEVEL_VENV)/bin/python setup.py develop
99
100 .PHONY: test_devel
101 test_devel:
102 $(DEVEL_VENV)/bin/python setup.py test -q
103
104 .PHONY: run_devel
105 run_devel:
106 $(DEVEL_VENV)/bin/pserve --reload development.ini
107
108 .PHONY: clean_devel_venv
109 clean_devel_venv:
110 rm -rf $(DEVEL_VENV)
111
112 .PHONY: clean_prod
113 clean_prod:
114 # Leave the $(MODWSGI_VENV) directory intact since it's ownwed by
115 # root and setgid with g=rwx.
116 rm -rf $(MODWSGI_VENV)/*
117
118 .PHONY: clean
119 clean:
120 rm -rf $(DEVEL_STUFF)
121
122 .PHONY: maintainerclean
123 maintainterclean: clean_devel_venv clean