|
| 1 | +# Configuration |
| 2 | +APP_ROOT := $(abspath $(lastword $(MAKEFILE_LIST))/..) |
| 3 | + |
| 4 | +# end of configuration |
| 5 | + |
| 6 | +define PRINT_HELP_PYSCRIPT |
| 7 | +import re, sys |
| 8 | + |
| 9 | +for line in sys.stdin: |
| 10 | + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) |
| 11 | + if match: |
| 12 | + target, help = match.groups() |
| 13 | + print("%-20s %s" % (target, help)) |
| 14 | + else: |
| 15 | + match = re.match(r'^## (.*)$$', line) |
| 16 | + if match: |
| 17 | + help = match.groups()[0] |
| 18 | + print("\n%s" % (help)) |
| 19 | +endef |
| 20 | +export PRINT_HELP_PYSCRIPT |
| 21 | + |
| 22 | +.DEFAULT_GOAL := help |
| 23 | + |
| 24 | +help: ## print this help message. (Default) |
| 25 | + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) |
| 26 | + |
| 27 | +## Build targets: |
| 28 | + |
| 29 | +install: ## install pywps |
| 30 | + @echo "Installing pywps ..." |
| 31 | + @-bash -c 'pip install -e .' |
| 32 | + |
| 33 | +develop: ## install pywps with development libraries |
| 34 | + @echo "Installing development requirements for tests and docs ..." |
| 35 | + @-bash -c 'pip install -e ".[dev]"' |
| 36 | + |
| 37 | +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts |
| 38 | + |
| 39 | +clean-build: ## remove build artifacts |
| 40 | + @echo "Removing build artifacts ..." |
| 41 | + @-rm -fr build/ |
| 42 | + @-rm -fr dist/ |
| 43 | + @-rm -fr .eggs/ |
| 44 | + @-find . -name '*.egg-info' -exec rm -fr {} + |
| 45 | + @-find . -name '*.egg' -exec rm -f {} + |
| 46 | + @-find . -name '*.log' -exec rm -fr {} + |
| 47 | + @-find . -name '*.sqlite' -exec rm -fr {} + |
| 48 | + |
| 49 | +clean-pyc: ## remove Python file artifacts |
| 50 | + @echo "Removing Python file artifacts ..." |
| 51 | + @-find . -name '*.pyc' -exec rm -f {} + |
| 52 | + @-find . -name '*.pyo' -exec rm -f {} + |
| 53 | + @-find . -name '*~' -exec rm -f {} + |
| 54 | + @-find . -name '__pycache__' -exec rm -fr {} + |
| 55 | + |
| 56 | +clean-test: ## remove test and coverage artifacts |
| 57 | + @echo "Removing test artifacts ..." |
| 58 | + @-rm -fr .tox/ |
| 59 | + @-rm -f .coverage |
| 60 | + @-rm -fr .pytest_cache |
| 61 | + |
| 62 | +clean-dist: clean ## remove git ignored files and directories |
| 63 | + @echo "Running 'git clean' ..." |
| 64 | + @git diff --quiet HEAD || echo "There are uncommitted changes! Aborting 'git clean' ..." |
| 65 | + ## do not use git clean -e/--exclude here, add them to .gitignore instead |
| 66 | + @-git clean -dfx |
| 67 | + |
| 68 | +clean-docs: ## remove documentation artifacts |
| 69 | + @echo "Removing documentation artifacts ..." |
| 70 | + $(MAKE) -C docs clean |
| 71 | + |
| 72 | +lint: ## check style with ruff |
| 73 | + @echo "Running code style checks ..." |
| 74 | + @bash -c 'ruff check pywps' |
| 75 | + |
| 76 | +## Testing targets: |
| 77 | + |
| 78 | +test: ## run tests quickly with the default Python (skip slow and online tests) |
| 79 | + @echo "Running tests (skip slow and online tests) ..." |
| 80 | + @bash -c 'pytest -v -m "not slow and not online" tests/' |
| 81 | + |
| 82 | +test-all: ## run all tests quickly with the default Python |
| 83 | + @echo "Running all tests (including slow and online tests) ..." |
| 84 | + @bash -c 'pytest -v tests/' |
| 85 | + |
| 86 | +## Sphinx targets: |
| 87 | + |
| 88 | +docs: clean-docs ## generate Sphinx HTML documentation, including API docs |
| 89 | + @echo "Generating docs with Sphinx ..." |
| 90 | + $(MAKE) -C docs html |
| 91 | + @echo "Open your browser to: file:/$(APP_ROOT)/docs/build/html/index.html" |
| 92 | + ## do not execute xdg-open automatically since it hangs ReadTheDocs and job does not complete |
| 93 | + @echo "xdg-open $(APP_ROOT)/docs/build/html/index.html" |
| 94 | + |
| 95 | + |
| 96 | +## Deployment targets: |
| 97 | + |
| 98 | +# dist: clean ## builds source and wheel package |
| 99 | +# python -m flit build |
| 100 | +# ls -l dist |
| 101 | + |
| 102 | +# release: dist ## package and upload a release |
| 103 | +# python -m flit publish dist/* |
| 104 | + |
0 commit comments