Commit

Add Makefile
Daniel Moch committed 5 years ago (Tree)

Diffstat

 {{cookiecutter.project_slug}}/Makefile | 77 ++++++++++++++++++++++++++++

{{cookiecutter.project_slug}}/Makefile (created)

1 +.PHONY: clean clean-test clean-pyc clean-build help
2 +.DEFAULT_GOAL := help
3 +
4 +define BROWSER_PYSCRIPT
5 +import os, webbrowser, sys
6 +
7 +try:
8 + from urllib import pathname2url
9 +except:
10 + from urllib.request import pathname2url
11 +
12 +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
13 +endef
14 +export BROWSER_PYSCRIPT
15 +
16 +define PRINT_HELP_PYSCRIPT
17 +import re, sys
18 +
19 +for line in sys.stdin:
20 + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
21 + if match:
22 + target, help = match.groups()
23 + print("%-20s %s" % (target, help))
24 +endef
25 +export PRINT_HELP_PYSCRIPT
26 +
27 +BROWSER := python -c "$$BROWSER_PYSCRIPT"
28 +{%- if cookiecutter.use_pipenv == 'y' %}
29 +PIPENV := pipenv run
30 +{%- else %}
31 +PIPENV :=
32 +{%- endif %}
33 +
34 +help:
35 + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
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 + rm -fr build/
41 + rm -fr dist/
42 + rm -fr .eggs/
43 + find . -name '*.egg-info' -exec rm -fr {} +
44 + find . -name '*.egg' -exec rm -f {} +
45 +
46 +clean-pyc: ## remove Python file artifacts
47 + find . -name '*.pyc' -exec rm -f {} +
48 + find . -name '*.pyo' -exec rm -f {} +
49 + find . -name '*~' -exec rm -f {} +
50 + find . -name '__pycache__' -exec rm -fr {} +
51 +
52 +clean-test: ## remove test and coverage artifacts
53 + rm -f .coverage
54 + rm -fr htmlcov/
55 + rm -fr .pytest_cache
56 +
57 +lint: ## check style with flake8
58 + $(PIPENV) pylint --rcfile tests/pylintrc {{ cookiecutter.project_slug }} tests
59 +
60 +test: ## run tests quickly with the default Python
61 + $(PIPENV) python -m pytest
62 +
63 +coverage: ## check code coverage quickly with the default Python
64 + $(PIPENV) coverage run --source {{ cookiecutter.project_slug }} -m pytest
65 + $(PIPENV) coverage report -m
66 + $(PIPENV) coverage html
67 + $(BROWSER) htmlcov/index.html
68 +
69 +release: dist ## package and upload a release
70 + $(PIPENV) flit publish
71 +
72 +dist: clean ## builds source and wheel package
73 + $(PIPENV) flit build
74 + ls -l dist
75 +
76 +install: clean ## install the package to the active Python's site-packages
77 + $(PIPENV) flit install