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))
94 # depending on the value of USE_TWINE, we either do the upload with setup.py itself,
95 # or with the help of twine which apparently is the only way that mario could find out on his setup
97 $(if $(USE_TWINE),./setup.py sdist && twine upload dist/* -r $(1),./setup.py sdist upload -r $(1))
100 # run this only once the sources are in on the right tag
102 @if [ $(GIT-CHANGES) != 0 ]; then echo "You have uncommitted changes - cannot publish"; false; fi
103 @if [ -n "$(GIT-TAG-ALREADY-SET)" ] ; then echo "tag $(VERSIONTAG) already set"; false; fi
104 @echo "You are about to release $(VERSION) - OK (Ctrl-c if not) ? " ; read _
105 git tag $(VERSIONTAG)
106 $(call upload_pypi,pypi)
107 @if [ ssh $(PYPI_TARBALL_HOST) ls $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAR) ] ;\
108 then echo "$(VERSIONTAR) already present on $(PYPI_TARBALL_HOST) - ignored" ;\
109 else rsync -av dist/$(VERSIONTAR) $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/ ;\
113 # it can be convenient to define a test entry, say testpypi, in your .pypirc
114 # that points at the testpypi public site
116 # no upload to build.onelab.eu is done in this case
118 # pip install -i https://testpypi.python.org/pypi nepi
119 # dependencies need to be managed manually though
120 $(call upload_pypi,testpypi)
122 #################### convenience, for debugging only
123 # make +foo : prints the value of $(foo)
124 # make ++foo : idem but verbose, i.e. foo=$(foo)
125 ++%: varname=$(subst +,,$@)
127 @echo "$(varname)=$($(varname))"
128 +%: varname=$(subst +,,$@)
130 @echo "$($(varname))"