~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
WD := $(shell pwd)
PY := bin/python
FLAKE8 := bin/flake8
PIP := bin/pip
CACHE := download-cache/dist
NOSE := INI="test.ini" bin/nosetests -v -s -x --mongodb
PSERVE := bin/pserve
SYSTEM_DEPS := \
	build-essential bzr charm-tools libyaml-dev mongodb-server \
	python-dev python-virtualenv python-xapian redis-server \
	subversion

# 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.
$(INI): development.ini
	cp development.ini $(INI)

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

install: charmworld.egg-info

venv: bin/python

bin/python:
	virtualenv .

charmworld.egg-info: deps bin/python $(INI)
	$(PY) setup.py develop

clean_venv:
	- rm -r bin include lib local

sysdeps:
	sudo apt-get install -y $(SYSTEM_DEPS);

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
	- ln -s /usr/lib/python2.7/dist-packages/xapian $(WD)/lib/python2.7/site-packages
	- rm -r build
	- rm -r share;

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

test: bin/nosetests
	$(NOSE) --with-id charmworld

testid:
	# Run specific nose id tests
	# Call with `make testid ID=3`
	$(NOSE) --with-id $(ID) charmworld

check: clear_ini clean install test

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)
	$(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
  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)