2 TESTDIR = $(CURDIR)/test
3 TESTLIB = $(TESTDIR)/lib
4 BUILDDIR = $(CURDIR)/build
5 DISTDIR = $(CURDIR)/dist
7 SUBBUILDDIR = $(shell python -c 'import distutils.util, sys; \
8 print "lib.%s-%s" % (distutils.util.get_platform(), \
10 PYTHON25 := $(shell python -c 'import sys; v = sys.version_info; \
11 print (1 if v[0] <= 2 and v[1] <= 5 else 0)')
14 BUILDDIR := $(BUILDDIR)/$(SUBBUILDDIR)
16 BUILDDIR := $(BUILDDIR)/lib
19 PYPATH = $(BUILDDIR):$(TESTLIB):$(PYTHONPATH)
20 COVERAGE = $(or $(shell which coverage), $(shell which python-coverage), \
24 PYTHONPATH="$(PYTHONPATH):$(SRCDIR)" ./setup.py build
27 PYTHONPATH="$(PYTHONPATH):$(SRCDIR)" ./setup.py install
31 for i in `find "$(TESTDIR)" -iname '*.py' -perm -u+x -type f`; do \
33 PYTHONPATH="$(PYPATH)" $$i -v || retval=$$?; \
38 PYTHONPATH="$(PYPATH)" $(file) $(case)
42 for i in `find "$(TESTDIR)" -perm -u+x -type f`; do \
44 PYTHONPATH="$(PYPATH)" $(COVERAGE) -x $$i -v; \
47 $(COVERAGE) -r -m `find "$(BUILDDIR)" -name \\*.py -type f`
51 rm -f `find -name \*.pyc` .coverage *.pcap
58 find . -path ./.hg\* -prune -o -path ./build -prune -o \
59 -name \*.pyc -prune -o -name \*.swp -prune -o \
60 -name MANIFEST -prune -o -type f -print | \
61 sed 's#^\./##' | sort > MANIFEST
66 .PHONY: all clean distclean dist test coverage install MANIFEST
68 ########## for uploading onto pypi
69 # this assumes you have an entry 'pypi' in your .pypirc
70 # see pypi documentation on how to create .pypirc
72 ifneq "$(LOCAL_ID)" "$(filter $(LOCAL_ID),parmen)"
79 PYPI_TARBALL_HOST=$(BUILD_ID)@build.onelab.eu
80 PYPI_TARBALL_TOPDIR=/build/nepi
82 VERSION=$(shell cat VERSION)
83 VERSIONTAG=nepi-$(VERSION)-pypi
84 VERSIONTAR=nepi-$(VERSION).tar.gz
85 ALREADY_SET=$(shell git tag | grep '^$(VERSIONTAG)$$')
87 # run this only once the sources are in on the right tag
89 @echo "Have you committed all changes (type Ctrl-c if not) ? " ; read _
90 @if [ -n "$(ALREADY_SET)" ] ; then echo "tag $(VERSIONTAG) already set"; false; fi
91 @echo "You are about to release $(VERSION) - OK (Ctrl-c if not) ? " ; read _
93 #./setup.py sdist upload -r pypi
95 twine upload dist/* -r pypi
96 @if [ ssh $(PYPI_TARBALL_HOST) ls $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAR) ] ;\
97 then echo "$(VERSIONTAR) already present on $(PYPI_TARBALL_HOST) - ignored" ;\
98 else rsync -av dist/$(VERSIONTAR) $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/ ;\
102 # it can be convenient to define a test entry, say testpypi
103 # that points at the testpypi public site
104 # in this case we do not want to upload anything on the build box though
107 #./setup.py sdist upload -r testpypi
109 twine upload dist/* -r testpypi
111 #################### convenience, for debugging only
112 # make +foo : prints the value of $(foo)
113 # make ++foo : idem but verbose, i.e. foo=$(foo)
114 ++%: varname=$(subst +,,$@)
116 @echo "$(varname)=$($(varname))"
117 +%: varname=$(subst +,,$@)
119 @echo "$($(varname))"