|
| 1 | +# Self-Documented Makefile see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html |
| 2 | + |
| 3 | +.DEFAULT_GOAL := help |
| 4 | +PART := minor |
| 5 | + |
| 6 | +# Put it first so that "make" without argument is like "make help". |
| 7 | +help: |
| 8 | + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-32s-\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
| 9 | + |
| 10 | +guard-%: ## Checks that env var is set else exits with non 0 mainly used in CI; |
| 11 | + @if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi |
| 12 | + |
| 13 | +# -------------------------------------------------------- |
| 14 | +# ------- Python package (pip) management commands ------- |
| 15 | +# -------------------------------------------------------- |
| 16 | + |
| 17 | +clean: clean-build clean-pyc ## remove all build and Python artifacts |
| 18 | + |
| 19 | +clean-build: ## remove build artifacts |
| 20 | + @rm -fr build/ |
| 21 | + @rm -fr dist/ |
| 22 | + @rm -fr .eggs/ |
| 23 | + @find . -name '*.egg-info' -exec rm -fr {} + |
| 24 | + @find . -name '*.egg' -exec rm -f {} + |
| 25 | + |
| 26 | +clean-pyc: ## remove Python file artifacts |
| 27 | + @find . -name '*.pyc' -exec rm -f {} + |
| 28 | + @find . -name '*.pyo' -exec rm -f {} + |
| 29 | + @find . -name '*~' -exec rm -f {} + |
| 30 | + @find . -name '__pycache__' -exec rm -fr {} + || true |
| 31 | + |
| 32 | +lint: ## check style with flake8 |
| 33 | + @flake8 github_deploy |
| 34 | + |
| 35 | +release: dist ## package and upload a release |
| 36 | + @twine upload dist/* |
| 37 | + |
| 38 | +dist: clean install-deploy ## builds source and wheel package |
| 39 | + @pip install twine==3.4.1 |
| 40 | + @python setup.py sdist bdist_wheel |
| 41 | + |
| 42 | +increase-version: guard-PART ## Increase project version |
| 43 | + @bump2version $(PART) |
| 44 | + @git switch -c main |
| 45 | + |
| 46 | +install-wheel: clean ## Install wheel |
| 47 | + @echo "Installing wheel..." |
| 48 | + @pip install wheel |
| 49 | + |
| 50 | +install: install-wheel ## install the package to the active Python's site-packages |
| 51 | + @pip install . |
| 52 | + |
| 53 | +install-deploy: install-wheel |
| 54 | + @pip install -e .'[deploy]' |
| 55 | + |
| 56 | +migrations: |
| 57 | + @python manage.py makemigrations |
| 58 | + |
| 59 | +.PHONY: clean clean-build clean-pyc dist increase-version install-wheel install install-deploy increase-version lint release migrations |
0 commit comments