Makefile 2.2 KB

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