-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
85 lines (60 loc) · 1.89 KB
/
Makefile
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
PYTHON_DIR=venv/bin
PYTHON=$(PYTHON_DIR)/python
PIP=$(PYTHON_DIR)/pip
GENERATE=generate/generic.py
SQLS=$(wildcard generate/*.sql)
GENERATED=$(foreach sql,$(SQLS),web/data/generated/$(basename $(notdir $(sql))).json)
DOWNLOAD=db/data/download
TABLES=$(wildcard db/data/*.sql) $(wildcard db/data/*.py)
FILES=$(DOWNLOAD)/standardised-returns.csv $(DOWNLOAD)/consents-processed.csv $(TABLES)
all: generated
.PHONY: python
python: $(PYTHON)
.python_uptodate: requirements.txt
python3 -m venv venv
$(PYTHON) -m pip install --upgrade pip
$(PIP) install -r $<
patch --forward -p0 -i python-patch.patch || true #bit yuk
touch $@
$(PYTHON): .python_uptodate
web/data/generated/%.json: generate/$(basename $(notdir %)).sql $(PYTHON) $(GENERATE) $(FILES)
@mkdir -p $(dir $@)
$(PYTHON) $(GENERATE) $< $@
.PHONY: clean
clean:
rm web/data/generated/*.json web/data/generated/chloropleth/chloro.json
generated: $(GENERATED) web/data/generated/chloropleth/chloro.json
.PHONY: it
it:
$(MAKE) generated
$(MAKE) -C js dev
.PHONY: watch
watch:
$(MAKE) it
while true; \
do \
inotifywait -q -r -e modify,create,delete .; \
$(MAKE) it; \
done
.PHONY: constituencies
constituencies: generate/constituencies/constituencies.py generate/constituencies/constituencies.sql
rm web/data/generated/constituencies/*.json
$(PYTHON) $< web/data/generated/constituencies
web/data/generated/chloropleth/chloro.json: generate/constituencies/cloropleth.py generate/constituencies/chloropleth.sql
mkdir -p $(dir $@)
$(PYTHON) $< $@
.PHONY: live-data-update
live-data-update:
$(PYTHON) api/thames-populate.py --update
$(PYTHON) api/rainfall-populate.py --update
@touch generate/thames-water-spills-daily.sql
$(PYTHON) api/thames-process.py
.PHONY: live-data
live-data: live-data-update web/data/generated/thames-water-spills-daily.json
.PHONY: prod
prod:
$(MAKE) generated
$(MAKE) -C js prod
.PHONY: ci
ci:
$(MAKE) -C js ci