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 ALREADY_SET=$(shell git tag | grep '^$(VERSIONTAG)$$')
92 # depending on the value of USE_TWINE, we either do the upload with setup.py itself,
93 # or with the help of twine which apparently is the only way that mario could find out on his setup
95 $(if $(USE_TWINE),./setup.py sdist && twine upload dist/* -r $(1),./setup.py sdist upload -r $(1))
98 # run this only once the sources are in on the right tag
100 @echo "Have you committed all changes (type Ctrl-c if not) ? " ; read _
101 @if [ -n "$(ALREADY_SET)" ] ; then echo "tag $(VERSIONTAG) already set"; false; fi
102 @echo "You are about to release $(VERSION) - OK (Ctrl-c if not) ? " ; read _
103 git tag $(VERSIONTAG)
104 $(call upload_pypi,pypi)
105 @if [ ssh $(PYPI_TARBALL_HOST) ls $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAR) ] ;\
106 then echo "$(VERSIONTAR) already present on $(PYPI_TARBALL_HOST) - ignored" ;\
107 else rsync -av dist/$(VERSIONTAR) $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/ ;\
111 # it can be convenient to define a test entry, say testpypi
112 # that points at the testpypi public site
113 # in this case we do not want to upload anything on the build box though
116 $(call upload_pypi,testpypi)
118 #################### convenience, for debugging only
119 # make +foo : prints the value of $(foo)
120 # make ++foo : idem but verbose, i.e. foo=$(foo)
121 ++%: varname=$(subst +,,$@)
123 @echo "$(varname)=$($(varname))"
124 +%: varname=$(subst +,,$@)
126 @echo "$($(varname))"