This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
200 lines (163 loc) · 7.41 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
VENV = venv
PYTHON_CMD = $(VENV)/bin/python
FLAKE8_CMD = $(VENV)/bin/flake8
AUTOPEP8_CMD = $(VENV)/bin/autopep8
PIP_CMD := $(VENV)/bin/pip
MAKO_CMD = $(VENV)/bin/mako-render
PREFIX ?= 1/
PYTHON_FILES := $(shell find scripts/* forge/* -name '*.py')
USERNAME := $(shell whoami)
TILEJSON_TEMPLATE ?= configs/raster/ch_swisstopo_swisstlm3d-wanderwege.cfg
MAX_LINE_LENGTH=90
PEP8_IGNORE="E128,E221,E241,E251,E272,E711,E731,W503"
# E128: continuation line under-indented for visual indent
# E221: multiple spaces before operator
# E241: multiple spaces after ':'
# E251: multiple spaces around keyword/parameter equals
# E272: multiple spaces before keyword
# E711: comparison to None should be 'if cond is None:' (SQLAlchemy's filter syntax requires this ignore!)
# E731: do not assign a lambda expression, use a def
# W503: line break before binary operator
.PHONY: help
help:
@echo "Usage: make <target>"
@echo
@echo "Possible targets:"
@echo
@echo "- install Install the app"
@echo "- lint Linter for python code"
@echo "- test Launch the tests"
@echo "- all All of the above"
@echo "- autolint Auto lint code styling"
@echo "- console Interactive psql console"
@echo "- create Create the database and user"
@echo "- createuser Create the user only"
@echo "- createdb Create the database only"
@echo "- setupfunctions Adds custom sql functions to the database"
@echo "- populate Populate the database with the TINs (shps)"
@echo "- populatelakes Populate the database with the lakes (polygons in WGS84)"
@echo "- dropdb Drop the database only"
@echo "- dropuser Drop the user only"
@echo "- destroy Drop the databasen and user"
@echo "- counttiles Count tiles in S3 bucket using a prexfix (usage: make counttiles PREFIX=12/)"
@echo "- deletetiles Delete tiles in S3 bucket using a prefix (usage: make deletetiles PREFIX=12/)"
@echo "- listtiles List tiles in S3 bucket using a prefix (usage: make listtiles PREFIX=12/)"
@echo "- tmspyramid Create the TMS pyramid based on the config file configs/terrain/tms.cfg"
@echo "- tmsmetadata Create the layers.json file (stored under 3d-forge/.tmp/layers.js)"
@echo "- tmsstats Provide statistics about the TMS pyramid"
@echo "- tmsstatsnodb Provide statistics about the TMS pyramid, without db stats"
@echo "- tmscreatequeue Creates AWS SQS queue with given settings (all tiles)"
@echo "- tmsdeletequeue Deletes current AWS SQS queue (you loose everything)"
@echo "- tmsqueuestats Get stats of AWS SQS queue"
@echo "- tmscreatetiles Creates tiles using the AWS SQS queue"
@echo "- tilejson Creates a tilejson provided a given template (usage: make tilejson TILEJSON_TEMPLATE=..."
@echo "- clean Clean all generated files"
@echo "- cleanall Clean all generated files and build tools"
@echo
@echo "Variables:"
@echo
@echo "- USERNAME (current value: $(USERNAME))"
@echo "- PYTHON_CMD (current value: $(PYTHON_CMD))"
@echo "- FLAKE8_CMD (current value: $(FLAKE8_CMD))"
@echo "- AUTOPEP8_CMD (current value: $(AUTOPEP8_CMD))"
@echo
.PHONY: all
all: install configs/terrain/database.cfg configs/terrain/tms.cfg configs/raster/database.cfg logging.cfg test lint
.PHONY: install
install:
( if [ -d "$(VENV)" ] ; then echo 'Skipping venv creation'; else virtualenv $(VENV) --system-site-packages && ${PIP_CMD} install Cython==0.28.4 --index-url https://pypi.fcio.net/simple/; fi ); \
${PIP_CMD} install --upgrade pip==19.2.3 setuptools==44.0.0 --index-url https://pypi.fcio.net/simple/ -e .;
configs/terrain/database.cfg:: configs/terrain/database.cfg.mako
$(MAKO_CMD) --var "pgpass=$(PGPASS)" --var "dbhost=$(DBHOST)" --var "username=$(USERNAME)" $< > $@
configs/terrain/tms.cfg:: configs/terrain/tms.cfg.mako
$(MAKO_CMD) --var "bucketname=$(BUCKETNAME)" --var "profilename=$(PROFILENAME)" $< > $@
configs/raster/database.cfg:: configs/raster/database.cfg.mako
$(MAKO_CMD) --var "dbhost=$(DBTARGETLAYER)" --var "username=$(PGUSERLAYER)" --var "pgpass=$(PGPASSLAYER)" $< > $@
logging.cfg: logging.cfg.mako
$(MAKO_CMD) --var "logfilefolder=$(LOGFILEFOLDER)" $< > $@
.PHONY: test
test:
$(VENV)/bin/nosetests tests/
.PHONY: lint
lint:
$(FLAKE8_CMD) --max-line-length=${MAX_LINE_LENGTH} --ignore=${PEP8_IGNORE} forge/
.PHONY: autolint
autolint:
@echo $(PYTHON_FILES)
$(AUTOPEP8_CMD) -v -i -a --max-line-length=${MAX_LINE_LENGTH} --ignore=${PEP8_IGNORE} $(PYTHON_FILES)
.PHONY: console
console:
$(PYTHON_CMD) scripts/db_management.py console
.PHONY: create
create: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py create
.PHONY: createuser
createuser: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py createuser
.PHONY: createdb
createdb: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py createdb
.PHONY: setupfunctions
setupfunctions: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py setupfunctions
.PHONY: populate
populate: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py populate
.PHONY: populatelakes
populatelakes: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py populatelakes
.PHONY: dropuser
dropuser: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py dropuser
.PHONY: dropuser
dropdb: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py dropdb
.PHONY: destroy
destroy: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/db_management.py destroy
.PHONY: counttiles
counttiles:
$(PYTHON_CMD) scripts/s3_tiles.py -p $(PREFIX) count
.PHONY: deletetiles
deletetiles:
$(PYTHON_CMD) scripts/s3_tiles.py -p $(PREFIX) delete
.PHONY: listtiles
listtiles:
$(PYTHON_CMD) scripts/s3_tiles.py -p $(PREFIX) list
.PHONY: tmspyramid
tmspyramid: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py create
.PHONY: tmsmetadata
tmsmetadata: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py metadata
.PHONY: tmsstats
tmsstats: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py stats
.PHONY: tmsstatsnodb
tmsstatsnodb: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py statsnodb
.PHONY: tmscreatequeue
tmscreatequeue: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py createqueue
.PHONY: tmsdeletequeue
tmsdeletequeue: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py deletequeue
.PHONY: tmscreatetiles
tmscreatetiles: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py createtiles
.PHONY: tmsqueuestats
tmsqueuestats: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tms_writer.py queuestats
.PHONY: tilejson
tilejson: configs/terrain/database.cfg configs/terrain/tms.cfg
$(PYTHON_CMD) scripts/tilejson_writer.py $(TILEJSON_TEMPLATE)
.PHONY: clean
clean:
rm -f configs/terrain/database.cfg
rm -f configs/terrain/tms.cfg
rm -f configs/raster/database.cfg
.PHONY: cleanall
cleanall: clean
rm -rf venv
rm -rf *.egg-info
rm -f .tmp/*.*