forked from svinota/pyroute2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
238 lines (212 loc) · 6.21 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
##
#
# The pyroute2 project is dual licensed, see README.license.md for details
#
#
##
# Python-related configuration
#
python ?= python
nosetests ?= nosetests
flake8 ?= flake8
pytest ?= pytest
##
# Python -W flags:
#
# ignore -- completely ignore
# default -- default action
# all -- print all warnings
# module -- print the first warning occurence for a module
# once -- print each warning only once
# error -- fail on any warning
#
# Would you like to know more? See man 1 python
#
wlevel ?= once
##
# Other options
#
# root -- install root (default: platform default)
# lib -- lib installation target (default: platform default)
# coverage -- whether to produce html coverage (default: false)
# pdb -- whether to run pdb on errors (default: false)
# module -- run only the specified test module (default: run all)
#
ifdef root
override root := "--root=${root}"
endif
ifdef lib
override lib := "--install-lib=${lib}"
endif
define list_modules
`ls -1 | sed -n '/egg-info/n; /pyroute2/p'`
endef
define make_modules
for module in $(call list_modules); do make -C $$module $(1) python=${python}; done
endef
define fetch_modules_dist
for module in $(call list_modules); do cp $$module/dist/* dist; done
endef
define clean_module
if [ -f $$module/setup.json ]; then \
for i in `ls -1 templates`; do rm -f $$module/$$i; done; \
fi; \
rm -f $$module/LICENSE.*; \
rm -f $$module/README.license.md; \
rm -f $$module/CHANGELOG.md; \
rm -f $$module/VERSION; \
rm -rf $$module/build; \
rm -rf $$module/dist; \
rm -rf $$module/*egg-info
endef
define process_templates
for module in $(call list_modules); do \
if [ -f $$module/setup.json ]; then \
for template in `ls -1 templates`; do \
${python} \
util/process_template.py \
templates/$$template \
$$module/setup.json \
$$module/$$template; \
done; \
fi; \
done
endef
define deploy_license
cp LICENSE.* $$module/ ; \
cp README.license.md $$module/ ; \
cp CHANGELOG.md $$module/
endef
all:
@echo targets:
@echo
@echo \* clean -- clean all generated files
@echo \* docs -- generate project docs \(requires sphinx\)
@echo \* test -- run functional tests \(see README.make.md\)
@echo \* install -- install lib into the system
@echo
clean:
@for module in $(call list_modules); do $(call clean_module); done
@rm -f VERSION
@rm -rf dist build MANIFEST
@rm -f docs-build.log
@rm -f docs/general.rst
@rm -f docs/changelog.rst
@rm -f docs/makefile.rst
@rm -f docs/report.rst
@rm -rf docs/api
@rm -rf docs/html
@rm -rf docs/doctrees
@[ -z "${keep_coverage}" ] && rm -f tests/.coverage ||:
@rm -rf tests/htmlcov
@[ -z "${keep_coverage}" ] && rm -rf tests/cover ||:
@rm -rf tests/examples
@rm -rf tests/bin
@rm -rf tests/pyroute2
@rm -f tests/*xml
@rm -f tests/tests.json
@rm -f tests/tests.log
@rm -rf pyroute2.egg-info
@rm -rf tests-workspaces
@rm -f python-pyroute2.spec
@rm -f pyroute2/config/version.py
@rm -f pyroute2/config.json
@rm -f pyroute2/setup.cfg
@rm -f pyroute2.minimal/config.json
@rm -f pyroute2.minimal/setup.cfg
@find pyroute2 -name "*pyc" -exec rm -f "{}" \;
@find pyroute2 -name "*pyo" -exec rm -f "{}" \;
VERSION:
@${python} util/update_version.py
@for package in $(call list_modules); do cp VERSION $$package; done
@for package in pyroute2 pyroute2.minimal; do \
echo '{"version": "'`cat $$package/VERSION`'"}' >$$package/config.json; \
done
docs/html:
@cp README.rst docs/general.rst
@cp README.make.md docs/makefile.rst
@cp README.report.md docs/report.rst
@cp CHANGELOG.md docs/changelog.rst
@[ -f docs/_templates/private.layout.html ] && ( \
mv -f docs/_templates/layout.html docs/_templates/layout.html.orig; \
cp docs/_templates/private.layout.html docs/_templates/layout.html; ) ||:
@export PYTHONPATH=`pwd`; \
make -C docs html || export FAIL=true ; \
[ -f docs/_templates/layout.html.orig ] && ( \
mv -f docs/_templates/layout.html.orig docs/_templates/layout.html; ) ||: ;\
unset PYTHONPATH ;\
[ -z "$$FAIL" ] || false
docs: install docs/html
check_parameters:
@if [ ! -z "${skip_tests}" ]; then \
echo "'skip_tests' is deprecated, use 'skip=...' instead"; false; fi
test: check_parameters
@export PYTHON=${python}; \
export NOSE=${nosetests}; \
export FLAKE8=${flake8}; \
export WLEVEL=${wlevel}; \
export SKIP_TESTS=${skip}; \
export PDB=${pdb}; \
export COVERAGE=${coverage}; \
export MODULE=${module}; \
export LOOP=${loop}; \
export REPORT=${report}; \
export WORKER=${worker}; \
export WORKSPACE=${workspace}; \
./tests/run.sh
pytest: check_parameters
@export PYTHON=${python}; \
export PYTEST=${pytest}; \
export FLAKE8=${flake8}; \
export WLEVEL=${wlevel}; \
export SKIP_TESTS=${skip}; \
export PDB=${pdb}; \
export COVERAGE=${coverage}; \
export MODULE=${module}; \
export LOOP=${loop}; \
export REPORT=${report}; \
export WORKER=${worker}; \
export WORKSPACE=${workspace}; \
export PYROUTE2_TEST_DBNAME=${dbname}; \
export SKIPDB=${skipdb}; \
./tests/run_pytest.sh
test-platform:
@${python} -c "\
import logging;\
logging.basicConfig();\
from pr2modules.config.test_platform import TestCapsRtnl;\
from pprint import pprint;\
pprint(TestCapsRtnl().collect())"
upload: dist
${python} -m twine upload dist/*
setup:
$(call process_templates)
@for module in $(call list_modules); do $(call deploy_license); done
@for module in pyroute2 pyroute2.minimal; do \
${python} \
util/process_template.py \
$$module/setup.cfg.in \
$$module/config.json \
$$module/setup.cfg ; \
done
dist: clean VERSION setup
cd pyroute2; ${python} setup.py sdist
mkdir dist
$(call make_modules, dist)
$(call fetch_modules_dist)
${python} -m twine check dist/*
install: dist
rm -f dist/pyroute2.minimal*
${python} -m pip install dist/* ${root}
install-minimal: dist
${python} -m pip install dist/pyroute2.minimal* dist/pyroute2.core* ${root}
uninstall: clean VERSION setup
$(call make_modules, uninstall)
audit-imports:
for module in $(call list_modules); do \
echo $$module; \
findimports -n $$module/pr2modules/ 2>/dev/null | awk -f util/imports_dict.awk | awk '{printf("\t"$$0"\n")}'; \
done
# deprecated:
epydoc clean-version update-version force-version README.md setup.ini develop:
@echo Deprecated target, see README.make.md