Debian Codegraph @

Makefile

raw
1 .DEFAULT_GOAL := help
2
3 REMOVE = python scripts/remove.py
4 BROWSER = python scripts/browser.py
5 COPYTREE = python scripts/copytree.py
6
7 DOCS_HTML_DIR = docs/_build/html
8 DOCS_HTML_STATIC = $(DOCS_HTML_DIR)/_static
9
10 .PHONY: help
11 help:
12 @python scripts/make-help.py < $(MAKEFILE_LIST)
13
14 .PHONY: venv
15 venv: ## creates a virtualenv using tox
16 tox -e dev
17
18 .PHONY: install
19 install: clean ## install the package in dev mode
20 pip install -e .
21
22 .PHONY: mypy
23 mypy: ## check code, tests and examples with mypy
24 mypy cloup --strict
25 mypy tests examples
26
27 .PHONY: lint
28 lint: ## check code, tests and examples with flake8
29 flake8 cloup tests examples
30
31 .PHONY: test
32 test: install ## run tests quickly with the default Python
33 pytest --cov=cloup -vv
34
35 .PHONY: coverage
36 coverage: test ## check code coverage quickly with the default Python
37 coverage report -m
38 coverage html
39 $(BROWSER) htmlcov/index.html
40
41 .PHONY: clean-docs
42 clean-docs: ## clean the documentation
43 $(MAKE) -C docs clean
44 $(REMOVE) docs/autoapi
45
46 .PHONY: docs
47 docs: ## generate Sphinx HTML documentation
48 $(MAKE) -C docs html
49
50 .PHONY: view-docs
51 view-docs: docs ## open the built docs in the default browser
52 $(BROWSER) $(DOCS_HTML_DIR)/index.html
53
54 .PHONY: re-docs
55 re-docs: clean-docs view-docs ## (re)generate Sphinx HTML documentation from scratch
56
57 LIVE_DOCS = sphinx-autobuild docs $(DOCS_HTML_DIR) \
58 --watch ./**.rst \
59 --watch ./cloup/**.py \
60 --ignore ./docs/autoapi/**.rst \
61 --open-browser
62
63 .PHONY: live-docs
64 live-docs: ## watch docs files and rebuild the docs when they change
65 $(LIVE_DOCS)
66
67 .PHONY: live-docs-all
68 live-docs-all: ## write all files (useful when working on html/css)
69 $(LIVE_DOCS) -a
70
71 .PHONY: update-docs-static
72 update-docs-static: ## copy docs static files into the build folder
73 $(COPYTREE) docs/_static $(DOCS_HTML_STATIC)
74
75 .PHONY: update-docs-css
76 update-docs-css: ## copy docs css files into the build folder
77 $(COPYTREE) docs/_static/styles $(DOCS_HTML_STATIC)/styles
78
79 .PHONY: clean
80 clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
81
82 .PHONY: clean-build
83 clean-build: ## remove build artifacts
84 $(REMOVE) build dist .eggs
85 $(REMOVE) -r './**/*.egg-info'
86 $(REMOVE) -r './**/*.egg'
87
88 .PHONY: clean-pyc
89 clean-pyc: ## remove Python file artifacts
90 $(REMOVE) -r './**/__pycache__'
91 $(REMOVE) -r './**/*.pyc'
92 $(REMOVE) -r './**/*.pyo'
93
94 .PHONY: clean-test
95 clean-test: ## remove test and coverage artifacts
96 $(REMOVE) .tox .coverage htmlcov .pytest_cache
97
98 .PHONY: dist
99 dist: clean-build ## builds source and wheel package
100 python setup.py sdist bdist_wheel
101 twine check dist/*
102
103 .PHONY: release
104 release: dist ## package and upload a release
105 twine upload dist/*
106
107 .PHONY: test-release
108 test-release: dist ## package and upload a release
109 twine upload --repository testpypi dist/*
110
111 PIP_COMPILE := pip-compile --allow-unsafe --resolver=backtracking --no-emit-index-url
112
113 .PHONY: pip-compile
114 pip-compile: ## pin dependencies in requirements/ using the current env
115 $(PIP_COMPILE) requirements/test.in
116 $(PIP_COMPILE) requirements/docs.in
117 $(PIP_COMPILE) requirements/dev.in
118
119 .PHONY: pip-upgrade
120 pip-upgrade: ## upgrade pip and dependencies
121 python -m pip install -U pip
122 $(PIP_COMPILE) --upgrade requirements/test.in
123 # $(PIP_COMPILE) --upgrade requirements/docs.in
124 $(PIP_COMPILE) --upgrade requirements/dev.in
125
126 .PHONY: pip-sync
127 pip-sync: ## sync development environment with requirements/dev.txt
128 pip install -U pip-tools
129 pip-sync requirements/dev.txt
130 pip install -e .