Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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
  25. BUILD_NUMBER ?= 1
  26. .PHONY: test dev clean extraclean debian/changelog
  27. all: egg
  28. egg: dist/$(EGG)
  29. dist/$(EGG):
  30. $(SETUP) bdist_egg
  31. sdist:
  32. $(SETUP) sdist
  33. debian/changelog:
  34. -git branch -D changelog
  35. git checkout -b changelog
  36. git-dch -a -N $(shell $(SETUP) --version) --debian-branch changelog \
  37. --snapshot --snapshot-number=$(BUILD_NUMBER)
  38. deb: debian/changelog
  39. test -d dist/deb || mkdir -p dist/deb
  40. dpkg-buildpackage -r$(ROOTCMD) -k$(SIGN_KEY)
  41. mv ../python-oauth2_* dist/deb
  42. test:
  43. $(SETUP) test --with-coverage --cover-package=oauth2
  44. sdist:
  45. python setup.py sdist
  46. xunit.xml: bin/nosetests $(SOURCES) $(TESTS)
  47. $(SETUP) test --with-xunit --xunit-file=$@
  48. bin/nosetests: bin/easy_install
  49. @$(EZ_INSTALL) nose
  50. coverage: .coverage
  51. @$(COVERAGE) html -d $@ $(COVERED)
  52. coverage.xml: .coverage
  53. @$(COVERAGE) xml $(COVERED)
  54. .coverage: $(SOURCES) $(TESTS) bin/coverage bin/nosetests
  55. -@$(COVERAGE) run $(SETUP) test
  56. bin/coverage: bin/easy_install
  57. @$(EZ_INSTALL) coverage
  58. profile: .profile bin/pyprof2html
  59. bin/pyprof2html -o $@ $<
  60. .profile: $(SOURCES) bin/nosetests
  61. -$(SETUP) test -q --with-profile --profile-stats-file=$@
  62. bin/pyprof2html: bin/easy_install bin/
  63. @$(EZ_INSTALL) pyprof2html
  64. docs: $(SOURCES) bin/epydoc
  65. @echo bin/epydoc -q --html --no-frames -o $@ ...
  66. @bin/epydoc -q --html --no-frames -o $@ $(SOURCES)
  67. bin/epydoc: bin/easy_install
  68. @$(EZ_INSTALL) epydoc
  69. bin/pep8: bin/easy_install
  70. @$(EZ_INSTALL) pep8
  71. pep8: bin/pep8
  72. @bin/pep8 --repeat --ignore E225 $(SRCDIR)
  73. pep8.txt: bin/pep8
  74. @bin/pep8 --repeat --ignore E225 $(SRCDIR) > $@
  75. lint: bin/pylint
  76. -$(PYLINT) -f colorized $(SRCDIR)
  77. lint.html: bin/pylint
  78. -$(PYLINT) -f html $(SRCDIR) > $@
  79. lint.txt: bin/pylint
  80. -$(PYLINT) -f parseable $(SRCDIR) > $@
  81. bin/pylint: bin/easy_install
  82. @$(EZ_INSTALL) pylint
  83. README.html: README.mkd | bin/markdown
  84. bin/markdown -e utf-8 $^ -f $@
  85. bin/markdown: bin/easy_install
  86. @$(EZ_INSTALL) Markdown
  87. # Development setup
  88. rtfm:
  89. $(PAGER) README.mkd
  90. tags: TAGS.gz
  91. TAGS.gz: TAGS
  92. gzip $^
  93. TAGS: $(SOURCES)
  94. ctags -eR .
  95. env: bin/easy_install
  96. bin/easy_install:
  97. $(VIRTUALENV) .
  98. -test -f deps/setuptools* && $@ -U deps/setuptools*
  99. dev: develop
  100. develop: env
  101. nice -n 20 $(SETUP) develop
  102. @echo " ---------------------------------------------"
  103. @echo " To activate the development environment, run:"
  104. @echo " . bin/activate"
  105. @echo " ---------------------------------------------"
  106. clean:
  107. clean:
  108. find . -type f -name \*.pyc -exec rm {} \;
  109. rm -rf build dist TAGS TAGS.gz digg.egg-info tmp .coverage \
  110. coverage coverage.xml docs lint.html lint.txt profile \
  111. .profile *.egg xunit.xml
  112. @if test "$(OS)" = "Linux"; then $(ROOTCMD) debian/rules clean; fi
  113. xclean: extraclean
  114. extraclean: clean
  115. rm -rf bin lib .Python include