|
1 |
| -ROOTCMD = fakeroot |
| 1 | +PYTHON = $(shell test -x bin/python && echo bin/python || \ |
| 2 | + echo `which python`) |
| 3 | +PYVERS = $(shell $(PYTHON) -c 'import sys; print "%s.%s" % sys.version_info[0:2]') |
| 4 | +VIRTUALENV = $(shell /bin/echo -n `which virtualenv || \ |
| 5 | + which virtualenv-$(PYVERS) || \ |
| 6 | + which virtualenv$(PYVERS)`) |
| 7 | +VIRTUALENV += --no-site-packages |
| 8 | +PAGER ?= less |
| 9 | +DEPS := $(shell find $(PWD)/deps -type f -printf "file://%p ") |
| 10 | +COVERAGE = $(shell test -x bin/coverage && echo bin/coverage || echo true) |
| 11 | +SETUP = $(PYTHON) ./setup.py |
| 12 | +EZ_INSTALL = $(SETUP) easy_install -f "$(DEPS)" |
| 13 | +PYLINT = bin/pylint |
| 14 | +PLATFORM = $(shell $(PYTHON) -c "from pkg_resources import get_build_platform; print get_build_platform()") |
| 15 | +OS := $(shell uname) |
| 16 | +EGG := $(shell $(SETUP) --fullname)-py$(PYVERS).egg |
| 17 | +SDIST := $(shell $(SETUP) --fullname).tar.gs |
| 18 | +SRCDIR := oauth2 |
| 19 | +SOURCES := $(shell find $(SRCDIR) -type f -name \*.py -not -name 'test_*') |
| 20 | +TESTS := $(shell find $(SRCDIR) -type f -name test_\*.py) |
| 21 | +COVERED := $(SOURCES) |
| 22 | +ROOT = $(shell pwd) |
| 23 | +ROOTCMD = fakeroot |
| 24 | +SIGN_KEY ?= nerds@simplegeo.com |
2 | 25 | BUILD_NUMBER ?= 1
|
3 | 26 |
|
4 |
| -.PHONY: debian/changelog |
| 27 | + |
| 28 | +.PHONY: test dev clean extraclean debian/changelog |
| 29 | + |
| 30 | +all: egg |
| 31 | +egg: dist/$(EGG) |
| 32 | + |
| 33 | +dist/$(EGG): |
| 34 | + $(SETUP) bdist_egg |
| 35 | + |
| 36 | +sdist: |
| 37 | + $(SETUP) sdist |
5 | 38 |
|
6 | 39 | debian/changelog:
|
7 | 40 | -git branch -D changelog
|
8 | 41 | git checkout -b changelog
|
9 |
| - git-dch -a -N $(shell python setup.py --version) --debian-branch changelog \ |
| 42 | + git-dch -a -N $(shell $(SETUP) --version) --debian-branch changelog \ |
10 | 43 | --snapshot --snapshot-number=$(BUILD_NUMBER)
|
11 | 44 |
|
12 |
| -dist: |
13 |
| - mkdir -p $@ |
14 |
| - |
15 |
| -deb: debian/changelog dist |
16 |
| - dpkg-buildpackage -r$(ROOTCMD) -us -uc |
17 |
| - mv ../python-oauth2_* dist/ |
| 45 | +deb: debian/changelog |
| 46 | + test -d dist/deb || mkdir -p dist/deb |
| 47 | + dpkg-buildpackage -r$(ROOTCMD) -k$(SIGN_KEY) |
| 48 | + mv ../python-oauth2_* dist/deb |
18 | 49 |
|
19 | 50 | test:
|
20 |
| - python setup.py test --with-coverage --cover-package=oauth2 |
| 51 | + $(SETUP) test --with-coverage --cover-package=oauth2 |
21 | 52 |
|
22 | 53 | sdist:
|
23 | 54 | python setup.py sdist
|
24 | 55 |
|
| 56 | +xunit.xml: bin/nosetests $(SOURCES) $(TESTS) |
| 57 | + $(SETUP) test --with-xunit --xunit-file=$@ |
| 58 | + |
| 59 | +bin/nosetests: bin/easy_install |
| 60 | + @$(EZ_INSTALL) nose |
| 61 | + |
| 62 | +coverage: .coverage |
| 63 | + @$(COVERAGE) html -d $@ $(COVERED) |
| 64 | + |
| 65 | +coverage.xml: .coverage |
| 66 | + @$(COVERAGE) xml $(COVERED) |
| 67 | + |
| 68 | +.coverage: $(SOURCES) $(TESTS) bin/coverage bin/nosetests |
| 69 | + -@$(COVERAGE) run $(SETUP) test |
| 70 | + |
| 71 | +bin/coverage: bin/easy_install |
| 72 | + @$(EZ_INSTALL) coverage |
| 73 | + |
| 74 | +profile: .profile bin/pyprof2html |
| 75 | + bin/pyprof2html -o $@ $< |
| 76 | + |
| 77 | +.profile: $(SOURCES) bin/nosetests |
| 78 | + -$(SETUP) test -q --with-profile --profile-stats-file=$@ |
| 79 | + |
| 80 | +bin/pyprof2html: bin/easy_install bin/ |
| 81 | + @$(EZ_INSTALL) pyprof2html |
| 82 | + |
| 83 | +docs: $(SOURCES) bin/epydoc |
| 84 | + @echo bin/epydoc -q --html --no-frames -o $@ ... |
| 85 | + @bin/epydoc -q --html --no-frames -o $@ $(SOURCES) |
| 86 | + |
| 87 | +bin/epydoc: bin/easy_install |
| 88 | + @$(EZ_INSTALL) epydoc |
| 89 | + |
| 90 | +bin/pep8: bin/easy_install |
| 91 | + @$(EZ_INSTALL) pep8 |
| 92 | + |
| 93 | +pep8: bin/pep8 |
| 94 | + @bin/pep8 --repeat --ignore E225 $(SRCDIR) |
| 95 | + |
| 96 | +pep8.txt: bin/pep8 |
| 97 | + @bin/pep8 --repeat --ignore E225 $(SRCDIR) > $@ |
| 98 | + |
| 99 | +lint: bin/pylint |
| 100 | + -$(PYLINT) -f colorized $(SRCDIR) |
| 101 | + |
| 102 | +lint.html: bin/pylint |
| 103 | + -$(PYLINT) -f html $(SRCDIR) > $@ |
| 104 | + |
| 105 | +lint.txt: bin/pylint |
| 106 | + -$(PYLINT) -f parseable $(SRCDIR) > $@ |
| 107 | + |
| 108 | +bin/pylint: bin/easy_install |
| 109 | + @$(EZ_INSTALL) pylint |
| 110 | + |
| 111 | +README.html: README.mkd | bin/markdown |
| 112 | + bin/markdown -e utf-8 $^ -f $@ |
| 113 | + |
| 114 | +bin/markdown: bin/easy_install |
| 115 | + @$(EZ_INSTALL) Markdown |
| 116 | + |
| 117 | + |
| 118 | +# Development setup |
| 119 | +rtfm: |
| 120 | + $(PAGER) README.mkd |
| 121 | + |
| 122 | +tags: TAGS.gz |
| 123 | + |
| 124 | +TAGS.gz: TAGS |
| 125 | + gzip $^ |
| 126 | + |
| 127 | +TAGS: $(SOURCES) |
| 128 | + ctags -eR . |
| 129 | + |
| 130 | +env: bin/easy_install |
| 131 | + |
| 132 | +bin/easy_install: |
| 133 | + $(VIRTUALENV) . |
| 134 | + -test -f deps/setuptools* && $@ -U deps/setuptools* |
| 135 | + |
| 136 | +dev: develop |
| 137 | +develop: env |
| 138 | + nice -n 20 $(SETUP) develop |
| 139 | + @echo " ---------------------------------------------" |
| 140 | + @echo " To activate the development environment, run:" |
| 141 | + @echo " . bin/activate" |
| 142 | + @echo " ---------------------------------------------" |
| 143 | + |
| 144 | +clean: |
25 | 145 | clean:
|
26 |
| - rm -rf dist && rm -fr *.egg && find . -name \*.pyc -print -delete |
27 |
| - $(ROOTCMD) debian/rules clean |
| 146 | + find . -type f -name \*.pyc -exec rm {} \; |
| 147 | + rm -rf build dist TAGS TAGS.gz digg.egg-info tmp .coverage \ |
| 148 | + coverage coverage.xml docs lint.html lint.txt profile \ |
| 149 | + .profile *.egg xunit.xml |
| 150 | + @if test "$(OS)" = "Linux"; then $(ROOTCMD) debian/rules clean; fi |
| 151 | + |
| 152 | + |
| 153 | +xclean: extraclean |
| 154 | +extraclean: clean |
| 155 | + rm -rf bin lib .Python include |
0 commit comments