forked from svinota/pyroute2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
163 lines (142 loc) · 4.26 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
# Copyright (c) 2013-2014 Peter V. Saveliev
#
# This file is part of pyroute2 project.
#
# Pyroute2 is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Pyroute2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyVFS; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
# Pyroute version and release
#
version ?= "0.3"
release := $(shell git describe)
##
# Python-related configuration
#
python ?= "python"
nosetests ?= "nosetests"
setuplib ?= "distutils.core"
##
# 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 (NB: default for our test cycle)
#
# Would you like to know more? See man 1 python
#
wlevel ?= "error"
##
# 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
ifdef coverage
override coverage := "--cover-html"
endif
ifdef pdb
override pdb := --pdb --pdb-failures
endif
ifdef wlevel
override wlevel := -W ${wlevel}
endif
all:
@echo targets: dist, install
clean: clean-version
rm -rf dist build MANIFEST
rm -f docs/general.rst
rm -f docs/changelog.rst
rm -f docs/makefile.rst
rm -rf docs/html
rm -rf docs/doctrees
rm -f tests/.coverage
rm -rf tests/htmlcov
rm -rf tests/cover
rm -rf pyroute2.egg-info
rm -f python-pyroute2.spec
find . -name "*pyc" -exec rm -f "{}" \;
find . -name "*pyo" -exec rm -f "{}" \;
setup.py docs/conf.py:
gawk -v version=${version}\
-v release=${release}\
-v setuplib=${setuplib}\
-f configure.gawk [email protected] >$@
clean-version:
rm -f setup.py
rm -f docs/conf.py
force-version: clean-version update-version
update-version: setup.py docs/conf.py
docs: clean force-version
cp README.md docs/general.rst
cp README.make.md docs/makefile.rst
cp CHANGELOG.md docs/changelog.rst
export PYTHONPATH=`pwd`; make -C docs html
test:
@export PYTHONPATH="`pwd`:`pwd`/examples"; cd tests; \
[ -z "$$VIRTUAL_ENV" ] || \
. $$VIRTUAL_ENV/bin/activate ; \
[ -z "$$VIRTUAL_ENV" ] || \
echo "Running in Virtualenv" ; \
[ "`id | sed 's/uid=[0-9]\+(\([A-Za-z]\+\)).*/\1/'`" = "root" ] && { \
echo "Running as root" ; \
ulimit -n 4096 ; \
modprobe dummy 2>/dev/null ||: ; \
modprobe bonding 2>/dev/null ||: ; \
modprobe 8021q 2>/dev/null ||: ; \
} ; \
echo "8<----------------------------------" ; \
echo "python: `which ${python}` [`${python} --version 2>&1`]" ; \
echo "flake8: `which flake8` [`flake8 --version 2>&1`]" ; \
echo "nosetests: `which ${nosetests}` [`${nosetests} --version 2>&1`]" ; \
echo "8<----------------------------------" ; \
flake8 --exclude=docs .. && echo "flake8 ... ok" || exit 250; \
[ -z "$$TRAVIS" ] && { \
${python} ${wlevel} `which ${nosetests}` -v ${pdb} \
--with-coverage \
--cover-package=pyroute2 \
${coverage} ${module} || exit 251; \
} ; \
cd .. ;
upload: clean force-version
${python} setup.py sdist upload
dist: clean force-version docs
${python} setup.py sdist
install: clean force-version
${python} setup.py install ${root} ${lib}
develop: setuplib = "setuptools"
develop: clean force-version
${python} setup.py develop
testdeps:
pip install coverage
pip install flake8
# 8<--------------------------------------------------------------------
#
# Packages
#
rpm: clean force-version
cp packages/RedHat/python-pyroute2.spec .
${python} setup.py sdist
rpmbuild -ta dist/*tar.gz