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 PYPI_TARBALL_HOST=root@build.onelab.eu
73 PYPI_TARBALL_TOPDIR=/build/nepi
75 VERSION=$(shell cat VERSION)
76 VERSIONTAG=nepi-$(VERSION)-pypi
77 VERSIONTAR=nepi-$(VERSION).tar.gz
78 ALREADY_SET=$(shell git tag | grep '^$(VERSIONTAG)$$')
80 # run this only once the sources are in on the right tag
82 @echo "Have you committed all changes (type Ctrl-c if not) ? " ; read _
83 @if [ -n "$(ALREADY_SET)" ] ; then echo "tag $(VERSIONTAG) already set"; false; fi
84 @echo "You are about to release $(VERSION) - OK (Ctrl-c if not) ? " ; read _
86 setup.py sdist upload -r pypi
87 @if [ ssh $(PYPI_TARBALL_HOST) ls $(PYPI_TARBALL_TOPDIR)/$(VERSIONTAR) ] ;\
88 then echo "$(VERSIONTAR) already present on $(PYPI_TARBALL_HOST) - ignored" ;\
89 else rsync -av dist/$(VERSIONTAR) $(PYPI_TARBALL_HOST):$(PYPI_TARBALL_TOPDIR)/ ;\
93 # it can be convenient to define a test entry, say testpypi
94 # that points at the testpypi public site
95 # in this case we do not want to upload anything on the build box though
98 setup.py sdist upload -r testpypi