Makefile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. .PHONY: clean clean-test clean-pyc clean-build docs help
  2. .DEFAULT_GOAL := help
  3. define BROWSER_PYSCRIPT
  4. import os, webbrowser, sys
  5. try:
  6. from urllib import pathname2url
  7. except:
  8. from urllib.request import pathname2url
  9. webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
  10. endef
  11. export BROWSER_PYSCRIPT
  12. define PRINT_HELP_PYSCRIPT
  13. import re, sys
  14. for line in sys.stdin:
  15. match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
  16. if match:
  17. target, help = match.groups()
  18. print("%-20s %s" % (target, help))
  19. endef
  20. export PRINT_HELP_PYSCRIPT
  21. BROWSER := python -c "$$BROWSER_PYSCRIPT"
  22. help:
  23. @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
  24. clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
  25. clean-build: ## remove build artifacts
  26. rm -fr build/
  27. rm -fr dist/
  28. rm -fr .eggs/
  29. find . -name '*.egg-info' -exec rm -fr {} +
  30. find . -name '*.egg' -exec rm -f {} +
  31. clean-pyc: ## remove Python file artifacts
  32. find . -name '*.pyc' -exec rm -f {} +
  33. find . -name '*.pyo' -exec rm -f {} +
  34. find . -name '*~' -exec rm -f {} +
  35. find . -name '__pycache__' -exec rm -fr {} +
  36. clean-test: ## remove test and coverage artifacts
  37. rm -fr .tox/
  38. rm -f .coverage
  39. rm -fr htmlcov/
  40. lint: ## check style with flake8
  41. flake8 check_de_embassy tests
  42. test: ## run tests quickly with the default Python
  43. python setup.py test
  44. test-all: ## run tests on every Python version with tox
  45. tox
  46. coverage: ## check code coverage quickly with the default Python
  47. coverage run --source check_de_embassy setup.py test
  48. coverage report -m
  49. coverage html
  50. $(BROWSER) htmlcov/index.html
  51. docs: ## generate Sphinx HTML documentation, including API docs
  52. rm -f docs/check_de_embassy.rst
  53. rm -f docs/modules.rst
  54. sphinx-apidoc -o docs/ check_de_embassy
  55. $(MAKE) -C docs clean
  56. $(MAKE) -C docs html
  57. $(BROWSER) docs/_build/html/index.html
  58. servedocs: docs ## compile the docs watching for changes
  59. watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
  60. release: clean ## package and upload a release
  61. python setup.py sdist upload
  62. python setup.py bdist_wheel upload
  63. dist: clean ## builds source and wheel package
  64. python setup.py sdist
  65. python setup.py bdist_wheel
  66. ls -l dist
  67. install: clean ## install the package to the active Python's site-packages
  68. python setup.py install