3 TESTDIR = $(CURDIR)/test
4 TESTLIB = $(TESTDIR)/lib
5 BUILDDIR = $(CURDIR)/build/lib
6 DISTDIR = $(CURDIR)/dist
8 PYPATH = $(BUILDDIR):$(TESTLIB):$(PYTHONPATH)
9 COVERAGE = $(or $(shell which coverage), $(shell which python-coverage), \
13 PYTHONPATH="$(PYTHONPATH):$(SRCDIR)" $(PYTHON) ./setup.py build
16 PYTHONPATH="$(PYTHONPATH):$(SRCDIR)" $(PYTHON) ./setup.py install
20 for i in `find "$(TESTDIR)" -iname '*.py' -perm -u+x -type f`; do \
22 PYTHONPATH="$(PYPATH)" $(PYTHON) $$i -v || retval=$$?; \
27 echo Run $(make) $@ file=test/some/path
31 PYTHONPATH="$(PYPATH)" $(PYTHON) $(file) $(case)
35 all-tests: test-app test-node
38 $(MAKE) test-one file=test/resources/linux/application.py case=$(case)
40 $(MAKE) test-one file=test/resources/linux/node.py case=$(case)
44 for i in `find "$(TESTDIR)" -perm -u+x -type f`; do \
46 PYTHONPATH="$(PYPATH)" $(COVERAGE) -x $$i -v; \
49 $(COVERAGE) -r -m `find "$(BUILDDIR)" -name \\*.py -type f`
53 rm -f $$(find . -name '*.pyc') .coverage *.pcap
60 find . -path ./.hg\* -prune -o -path ./build -prune -o \
61 -name \*.pyc -prune -o -name \*.swp -prune -o \
62 -name MANIFEST -prune -o -type f -print | \
63 sed 's#^\./##' | sort > MANIFEST
68 .PHONY: all clean distclean dist test coverage install MANIFEST
70 ########## for uploading onto pypi
71 # this assumes you have an entry 'pypi' in your .pypirc
72 # see pypi documentation on how to create .pypirc
74 ifneq "$(LOCAL_ID)" "$(filter $(LOCAL_ID),parmen)"
83 PYPI_TARBALL_HOST=$(BUILD_ID)@build.onelab.eu
84 PYPI_TARBALL_TOPDIR=/build/nepi
86 VERSION = $(shell cat VERSION)
87 VERSIONTAG = nepi-$(VERSION)-pypi
88 VERSIONTAR = nepi-$(VERSION).tar.gz
89 GIT-TAG-ALREADY-SET = $(shell git tag | grep '^$(VERSIONTAG)$$')
90 # to check for uncommitted changes
91 GIT-CHANGES = $(shell echo $$(git diff HEAD | wc -l))
92 GIT-URL = git://git.onelab.eu/nepi.git
94 version: nepi/util/version.py
95 nepi/util/version.py: VERSION nepi/util/version.py.in
96 sed -e "s,@VERSIONTAG@,$(VERSION),g" -e "s,@SCMURL@,$(GIT-URL),g" nepi/util/version.py.in > $@
100 rm -f nepi/util/version.py
103 # depending on the value of USE_TWINE, we either do the upload with setup.py itself,
104 # or with the help of twine which apparently is the only way that mario could find out on his setup
106 $(if $(USE_TWINE),./setup.py sdist && twine upload dist/* -r $(1),./setup.py sdist upload -r $(1))
109 # run this only once the sources are in on the right tag
111 @if [ $(GIT-CHANGES) != 0 ]; then echo "You have uncommitted changes - cannot publish"; false; fi
112 @if [ -n "$(GIT-TAG-ALREADY-SET)" ] ; then echo "tag $(VERSIONTAG) already set"; false; fi
113 @echo "You are about to release $(VERSION) - OK (Ctrl-c if not) ? " ; read _
114 git tag $(VERSIONTAG)
115 $(call upload_pypi,pypi)
116 @if [ ssh $(PYPI_TARBALL_HOST) ls $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAR) ] ;\
117 then echo "$(VERSIONTAR) already present on $(PYPI_TARBALL_HOST) - ignored" ;\
118 else rsync -av dist/$(VERSIONTAR) $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/ ;\
122 # it can be convenient to define a test entry, say testpypi, in your .pypirc
123 # that points at the testpypi public site
124 # no upload to build.onelab.eu is done in this case
126 # pip install -i https://testpypi.python.org/pypi nepi
127 # dependencies need to be managed manually though
129 $(call upload_pypi,testpypi)
131 #################### convenience, for debugging only
132 # make +foo : prints the value of $(foo)
133 # make ++foo : idem but verbose, i.e. foo=$(foo)
134 ++%: varname=$(subst +,,$@)
136 @echo "$(varname)=$($(varname))"
137 +%: varname=$(subst +,,$@)
139 @echo "$($(varname))"