-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
108 lines (79 loc) · 2.74 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
VENV_PATH ?= .venv
VENV_REQUIREMENTS = $(VENV_PATH)/.timestamp
PIP_REQUIREMENTS = $(VENV_PATH)/.requirements-timestamp
DOC_REQUIREMENTS = $(VENV_PATH)/.doc-requirements-timestamp
VENV_BIN = $(VENV_PATH)/bin
PIP_COMMAND = pip3
PYTHON_PATH = $(shell which python3)
PYTHON_VERSION = $(shell printf '%b' "import sys\nprint(f'{sys.version_info.major}.{sys.version_info.minor}')" | $$(which python3))
QGIS_VENV_PATH = $(VENV_PATH)/lib/python$(PYTHON_VERSION)/site-packages/qgis_paths.pth
QGIS_PY_PATH ?= /usr/share/qgis/python
# ********************
# Variable definitions
# ********************
# Package name
PACKAGE = qgis_server_light
LOCATION ?= ./src
# Python source files
SRC_PY = $(shell find $(LOCATION)/$(PACKAGE) -name '*.py')
# Environment variables used for build
BUILD_ENV += \
DEVELOPMENT=${DEVELOPMENT}
# *******************
# Set up environments
# *******************
$(VENV_REQUIREMENTS):
$(PYTHON_PATH) -m venv $(VENV_PATH) --system-site-packages
touch $@
$(QGIS_VENV_PATH):
echo "/usr/share/qgis/python" > $@
$(PIP_REQUIREMENTS): $(VENV_REQUIREMENTS) requirements.interface.txt requirements.worker.txt requirements.exporter.txt $(QGIS_VENV_PATH)
$(VENV_BIN)/$(PIP_COMMAND) install --upgrade pip wheel
$(VENV_BIN)/$(PIP_COMMAND) install -r requirements.interface.txt -r requirements.worker.txt -r requirements.exporter.txt
touch $@
$(DOC_REQUIREMENTS): $(PIP_REQUIREMENTS) requirements.docs.txt
$(VENV_BIN)/$(PIP_COMMAND) install -r requirements.docs.txt
touch $@
# **************
# Common targets
# **************
# Build dependencies
BUILD_DEPS += $(PIP_REQUIREMENTS)
.PHONY: install
install: $(PIP_REQUIREMENTS)
.PHONY: install-docs
install-docs: $(PIP_REQUIREMENTS) $(DOC_REQUIREMENTS)
.PHONY: build
build: $(BUILD_DEPS)
$(VENV_BIN)/python setup.py bdist_wheel
.PHONY: clean
clean:
.PHONY: clean-all
clean-all: clean
rm -rf $(VENV_PATH)
rm -rf src/$(PACKAGE).egg-info
.PHONY: git-attributes
git-attributes:
git --no-pager diff --check `git log --oneline | tail -1 | cut --fields=1 --delimiter=' '`
.PHONY: test
test: $(PIP_REQUIREMENTS) $(VARS_FILES)
$(VENV_BIN)/py.test -vv --cov-config .coveragerc --cov $(PACKAGE) --cov-report term-missing:skip-covered tests
.PHONY: doc-html
doc-html: $(DOC_REQUIREMENTS) docs/mkdocs.yml
rm -rf doc/site
$(VENV_BIN)/mkdocs build -f docs/mkdocs.yml -d site
.PHONY: doc-serve
doc-serve: $(DOC_REQUIREMENTS) docs/mkdocs.yml
$(VENV_BIN)/mkdocs serve -f docs/mkdocs.yml
.PHONY: doc-gh-deploy
doc-gh-deploy: $(DOC_REQUIREMENTS) docs/mkdocs.yml
$(VENV_BIN)/mkdocs gh-deploy -f docs/mkdocs.yml -d site --force
.PHONY: updates
updates: $(PIP_REQUIREMENTS)
$(VENV_BIN)/pip list --outdated
.PHONY: dev
dev: setup.py build
$(VENV_BIN)/python $< develop
.PHONY: serve
serve: build
$(VENV_BIN)/pserve application.ini