|
| 1 | +.PHONY: clean clean-test clean-pyc clean-build docs help |
| 2 | +.DEFAULT_GOAL := help |
| 3 | + |
| 4 | +define BROWSER_PYSCRIPT |
| 5 | +import os, webbrowser, sys |
| 6 | + |
| 7 | +from urllib.request import pathname2url |
| 8 | + |
| 9 | +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) |
| 10 | +endef |
| 11 | +export BROWSER_PYSCRIPT |
| 12 | + |
| 13 | +define PRINT_HELP_PYSCRIPT |
| 14 | +import re, sys |
| 15 | + |
| 16 | +for line in sys.stdin: |
| 17 | + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) |
| 18 | + if match: |
| 19 | + target, help = match.groups() |
| 20 | + print("%-20s %s" % (target, help)) |
| 21 | +endef |
| 22 | +export PRINT_HELP_PYSCRIPT |
| 23 | + |
| 24 | +BROWSER := python -c "$$BROWSER_PYSCRIPT" |
| 25 | +aws_password := $(shell aws codeartifact get-authorization-token --domain pip-clariteia --domain-owner 785264909821 --query authorizationToken --output text) |
| 26 | +aws_repo_url := $(shell aws codeartifact get-repository-endpoint --domain pip-clariteia --domain-owner 785264909821 --repository minos --format pypi --query repositoryEndpoint --output text) |
| 27 | + |
| 28 | +help: |
| 29 | + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) |
| 30 | + |
| 31 | +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts |
| 32 | + |
| 33 | +clean-build: ## remove build artifacts |
| 34 | + rm -fr build/ |
| 35 | + rm -fr dist/ |
| 36 | + rm -fr .eggs/ |
| 37 | + find . -name '*.egg-info' -exec rm -fr {} + |
| 38 | + find . -name '*.egg' -exec rm -f {} + |
| 39 | + |
| 40 | +clean-pyc: ## remove Python file artifacts |
| 41 | + find . -name '*.pyc' -exec rm -f {} + |
| 42 | + find . -name '*.pyo' -exec rm -f {} + |
| 43 | + find . -name '*~' -exec rm -f {} + |
| 44 | + find . -name '__pycache__' -exec rm -fr {} + |
| 45 | + |
| 46 | +clean-test: ## remove test and coverage artifacts |
| 47 | + rm -fr .tox/ |
| 48 | + rm -f .coverage |
| 49 | + rm -fr htmlcov/ |
| 50 | + rm -fr .pytest_cache |
| 51 | + |
| 52 | +lint: ## check style with flake8 |
| 53 | + flake8 minos tests |
| 54 | + |
| 55 | +test: ## run tests quickly with the default Python |
| 56 | + pytest |
| 57 | + |
| 58 | +test-all: ## run tests on every Python version with tox |
| 59 | + tox |
| 60 | + |
| 61 | +coverage: ## check code coverage quickly with the default Python |
| 62 | + coverage run --source minos -m pytest |
| 63 | + coverage report -m |
| 64 | + coverage html |
| 65 | + $(BROWSER) htmlcov/index.html |
| 66 | + |
| 67 | +docs: ## generate Sphinx HTML documentation, including API docs |
| 68 | + rm -f docs/api_gateway.rst |
| 69 | + rm -f docs/modules.rst |
| 70 | + sphinx-apidoc -o docs/ api_gateway |
| 71 | + $(MAKE) -C docs clean |
| 72 | + $(MAKE) -C docs html |
| 73 | + $(BROWSER) docs/_build/html/index.html |
| 74 | + |
| 75 | +servedocs: docs ## compile the docs watching for changes |
| 76 | + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . |
| 77 | + |
| 78 | +release: dist ## package and upload a release |
| 79 | + twine upload --repository-url $(aws_repo_url) --username aws --password $(aws_password) dist/* |
| 80 | + |
| 81 | +dist: clean ## builds source and wheel package |
| 82 | + python setup.py sdist |
| 83 | + python setup.py bdist_wheel |
| 84 | + ls -l dist |
| 85 | + |
| 86 | +install: clean ## install the package to the active Python's site-packages |
| 87 | + python setup.py install |
0 commit comments