~jcsackett/charmworld/bac-tag-constraints

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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
WD := $(shell pwd)
PY := bin/python
FLAKE8 := bin/flake8
PIP := bin/pip
CACHE := download-cache/dist
CSS_PATH := charmworld/static/css
LESSC := node_modules/less/bin/lessc
NOSE := INI="test.ini" bin/nosetests
PSERVE := bin/pserve
SYSTEM_DEPS := \
	build-essential bzr charm-tools libyaml-dev python-dev python-virtualenv\
	python-xapian subversion npm


# Default ini file to use for all scripted commands. Can be overridden by
# specifying  INI=development.ini
INI = charmworld.ini

# INI is the default ini file used for all work. By default we want to copy a
# sample.ini and generate a single charmworld.ini used.

ifeq ($(wildcard custom.ini), )
	CONFIG_DEPS = default.ini
else
	CONFIG_DEPS = default.ini custom.ini
endif


$(INI): $(CONFIG_DEPS)
	scripts/config $(INI) $(CONFIG_DEPS)

test.ini: default.ini test-setup.ini
	scripts/config test.ini default.ini test-setup.ini

# ###############
# INSTALL targets
# ###############

install: charmworld.egg-info

venv: bin/python

bin/python:
	virtualenv .

# Made PHONY so that setup.py develop is rerun to include new entry point for
# mongo sessions.
.PHONY: charmworld.egg-info
charmworld.egg-info: deps bin/python $(INI) charmworld/static/css/theme.css
	$(PY) setup.py develop

clean_venv:
	- rm -r bin include lib local

css: charmworld/static/css/theme.css
charmworld/static/css/theme.css: $(LESSC) $(CSS_PATH)/theme.less $(CSS_PATH)/variables.less
	./$(LESSC) --compress $(CSS_PATH)/theme.less $(CSS_PATH)/theme.css

sysdeps:
	sudo add-apt-repository -y ppa:juju/pkgs
	sudo apt-get update
	sudo apt-get install -y $(SYSTEM_DEPS) mongodb-server;
	# On quantal need to provide node bin for deps to work.
	- sudo ln -s /usr/bin/nodejs /usr/bin/node

deploy_sysdeps:
	sudo apt-get install -y $(SYSTEM_DEPS) mongodb-clients;

deps: venv
	if test -d download-cache; \
		then bzr up download-cache; \
		else bzr checkout lp:~juju-jitsu/charmworld/download-cache; \
	fi
	$(PIP) install --no-index --no-dependencies --find-links file:///$(WD)/$(CACHE) -r requirements.txt
	npm install download-cache/npm/ycssmin.tar.gz
	npm install download-cache/npm/less.tar.gz
	- ln -s /usr/lib/python2.7/dist-packages/xapian $(WD)/lib/python2.7/site-packages
	- rm -r build
	- rm -r share;

# ###################
# Development helpers
# ###################

test: test.ini bin/nosetests
	$(NOSE) charmworld

testid: test.ini bin/nosetests
	# Run specific nose id tests
	# Call with `make testid ID=3`
	$(NOSE) -v -s -x --with-id $(ID) charmworld

test_migration: test.ini bin/nosetests
	$(NOSE) --with-id migrations

testdebug: test.ini bin/nosetests
	$(NOSE) --with-id --pdb --pdb-failures charmworld

check: clear_ini clean sysdeps install testid

lint: sources = setup.py charmworld
lint:
	@find $(sources) -name '*.py' ! -path '*/migrations/*' \
	    ! -print0 | xargs -r0 \
		bin/flake8 --ignore=E125,E127

# Generate ctags for the code in the project.
tags:
	ctags --tag-relative --python-kinds=-iv -Rf tags --sort=yes --exclude=.bzr --languages=python

doc: bin/sphinx-build
	bin/sphinx-build docs docs/_build/html

doc-open: doc
	xdg-open docs/_build/html/index.html

doc-upload: doc
	scp -r docs/_build/html/* people.canonical.com:/home/rharding/public_html/charmworld

run: $(INI) charmworld/static/css/theme.css
	$(PSERVE) --reload --monitor-restart $(INI)

clean:
	find . -type f -name '*.py[co]' -print0 | xargs -r0 $(RM)
	find . -type f -name '*~' -print0 | xargs -r0 $(RM)

clear_ini:
	- rm charmworld.ini

distclean: clean clean_venv
	$(RM) tags TAGS .installed.cfg


#
# Phony stuff.
#
define phony_targets
  check
  css
  clean_venv
  clean
  deploy
  deps
  distclean
  doc
  doc-open
  install
  lint
  run
  tags
  test
  testid
  venv
endef

define phony
  $(phony_targets)
endef

phony := $(sort $(strip $(phony)))

.PHONY: $(phony)