-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (102 loc) · 3.44 KB
/
Copy pathMakefile
File metadata and controls
122 lines (102 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.DEFAULT_GOAL := help
sources = src tests
notebooks-sources = notebooks
.PHONY: install ## Install the package, dependencies, and pre-commit for local development
install:
python -m pip install -U pip
python -m pip install -e .[lint,test,dev,build,docs,notebooks]
python -m pre_commit install --install-hooks
python -m pre_commit install --hook-type commit-msg
.PHONY: format ## Auto-format python source files
format:
python -m black $(sources)
python -m ruff check --fix $(sources)
python -m ruff format $(sources)
.PHONY: format-notebooks ## Auto-format Jupyter Notebooks
format-notebooks:
python -m black $(notebooks-sources)
python -m ruff check --fix $(notebooks-sources)
python -m ruff format $(notebooks-sources)
.PHONY: lint ## Lint python source files
lint:
python -m ruff check $(sources)
python -m ruff format --check $(sources)
python -m black $(sources) --check --diff
.PHONY: lint-notebooks ## Lint Jupyter Notebooks
lint-notebooks:
python -m ruff check $(notebooks-sources)
python -m ruff format --check $(notebooks-sources)
python -m black $(notebooks-sources) --check --diff
.PHONY: codespell ## Use Codespell to do spellchecking
codespell:
python -m codespell_lib
.PHONY: typecheck ## Perform type-checking
typecheck:
python -m mypy
.PHONY: audit ## Use pip-audit to scan for known vulnerabilities
audit:
python -m pip_audit .
.PHONY: test ## Run all unit tests and generate a coverage report
test:
python -m pytest -m "not integration" --cov-report term --cov-report=xml --cov=$(sources)
.PHONY: test-integration ## Run only integration tests (if configured) without generate a coverage report
test-integration:
python -m pytest -m "integration" -rs -n auto --dist=loadscope --maxfail=5 --durations=10 --tb=short
.PHONY: pre-commit ## Run all pre-commit hooks
pre-commit:
python -m pre_commit run --all-files
.PHONY: all ## Run the standard set of checks performed in CI
all: lint codespell typecheck audit test
.PHONY: clean ## Clear local caches and build artifacts
clean:
# remove Python file artifacts
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]'`
rm -f `find . -type f -name '*~'`
rm -f `find . -type f -name '.*~'`
rm -rf .cache
rm -rf .mypy_cache
rm -rf .ruff_cache
# remove build artifacts
rm -rf build
rm -rf dist
rm -rf `find . -name '*.egg-info'`
rm -rf `find . -name '*.egg'`
# remove test and coverage artifacts
rm -rf .tox/
rm -f .coverage
rm -f .coverage.*
rm -rf coverage.*
rm -rf htmlcov/
rm -rf .pytest_cache
rm -rf htmlcov
.PHONY: docs ## Generate HTML documentation
docs:
$(MAKE) -C docs clean
$(MAKE) -C docs html
.PHONY: servedocs ## Build, watch and serve documentation with live reload in the browser
servedocs:
$(MAKE) -C docs livehtml
.PHONY: notebooks ## Run notebooks
notebooks:
PYTHONHASHSEED=42 python -m jupyterlab
.PHONY: build ## Build source and wheel distributions
build: all clean
python -m build
.PHONY: distcheck ## Validate built distributions
distcheck: build
gunzip -tv dist/*.tar.gz
zip -T dist/*.whl
pyroma --min=10 dist/*.tar.gz
python -m twine check dist/* --strict
check-wheel-contents dist/*.whl
pydistcheck dist/*
.PHONY: publish ## Publish the built distributions to PyPI
publish: distcheck
python -m twine upload dist/* --verbose
.PHONY: help ## Display this message
help:
@grep -E \
'^.PHONY: .*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ".PHONY: |## "}; {printf "\033[36m%-19s\033[0m %s\n", $$2, $$3}'