forked from gammapy/gammapy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
144 lines (125 loc) · 4.91 KB
/
Makefile
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Makefile with some convenient quick ways to do common things
PROJECT = gammapy
CYTHON ?= cython
version = dev
release = $(version)
help:
@echo ''
@echo ' make targets:'
@echo ''
@echo ' help Print this help message (the default)'
@echo ''
@echo ' clean Remove generated files'
@echo ' clean-repo Remove all untracked files and directories (use with care!)'
@echo ''
@echo ' test Run pytest'
@echo ' test-cov Run pytest with coverage'
@echo ''
@echo ' docs-sphinx Build docs (Sphinx only)'
@echo ' docs-show Open local HTML docs in browser'
@echo ''
@echo ' trailing-spaces Remove trailing spaces at the end of lines in *.py files'
@echo ' black Run black code formatter'
@echo ' isort Run isort code formatter to sort imports'
@echo ' polish Run trailing-spaces, black and isort'
@echo ''
@echo ' flake8 Run flake8 static code analysis'
@echo ' pylint Run pylint static code analysis'
@echo ' pydocstyle Run docstring checks'
@echo ' dataset-index Create download dataset index json file'
@echo ''
@echo ' Note that most things are done via `python setup.py`, we only use'
@echo ' make for things that are not trivial to execute via `setup.py`.'
@echo ''
@echo ' setup.py commands:'
@echo ''
@echo ' python setup.py --help-commands'
@echo ' python setup.py install'
@echo ' python setup.py bdist_conda'
@echo ' python setup.py develop'
@echo ''
@echo ' To get info about your Gammapy installation and setup run this command'
@echo ''
@echo ' gammapy info'
@echo ''
@echo ' For this to work, Gammapy needs to be installed and on your PATH.'
@echo ' If it is not, then use this equivalent command:'
@echo ''
@echo ' python -m gammapy info'
@echo ''
@echo ' More info:'
@echo ''
@echo ' * Gammapy code: https://github.com/gammapy/gammapy'
@echo ' * Gammapy docs: https://docs.gammapy.org/'
@echo ''
@echo ' Most common commands to hack on Gammapy:'
@echo ''
@echo ' make help Print help message with all commands'
@echo ' pip install -e . Install Gammapy in editable mode'
@echo ' gammapy info Check install and versions'
@echo ' make clean Remove auto-generated files'
@echo ' pytest Run Gammapy tests (give folder or filename and options)'
@echo ' make test-cov Run all tests and measure coverage'
@echo ' make docs-sphinx Build documentation locally'
@echo ''
clean:
rm -rf build dist docs/_build docs/api temp/ docs/_static/notebooks \
htmlcov MANIFEST v gammapy.egg-info .eggs .coverage .cache .pytest_cache \
docs/modeling/gallery
find . -name ".ipynb_checkpoints" -prune -exec rm -rf {} \;
find . -name "*.pyc" -exec rm {} \;
find . -name "*.reg" -exec rm {} \;
find . -name "*.so" -exec rm {} \;
find gammapy -name '*.c' -exec rm {} \;
find . -name __pycache__ | xargs rm -fr
clean-repo:
@git clean -f -x -d
test:
python -m pytest -v gammapy
test-cov:
python -m pytest -v gammapy --cov=gammapy --cov-report=html
docs-sphinx:
cd docs && python -m sphinx . _build/html -b html -j auto
cp docs/binder/runtime.txt docs/_build/html/binder
docs-show:
python docs/serve.py
trailing-spaces:
find $(PROJECT) examples docs -name "*.py" -exec perl -pi -e 's/[ \t]*$$//' {} \;
black:
black $(PROJECT)/ examples/ docs/ \
--exclude="extern/|docs/_static|docs/_build" \
--line-length 88
isort:
isort -rc gammapy examples docs -s docs/conf.py
polish: black isort trailing-spaces;
# Note: flake8 is very fast and almost never has false positives
flake8:
flake8 $(PROJECT) \
--exclude=gammapy/extern,gammapy/conftest.py,__init__.py \
--ignore=E501,W503
# TODO: once the errors are fixed, remove the -E option and tackle the warnings
# Note: pylint is very thorough, but slow, and has false positives or nitpicky stuff
pylint:
pylint -E $(PROJECT)/ \
--ignore=gammapy/extern \
-d E0611,E1101,E1103 \
--msg-template='{C}: {path}:{line}:{column}: {msg} ({symbol})'
# TODO: fix and re-activate check for the following:
# D103: Missing docstring in public function
# D202: No blank lines allowed after function docstring (found 1)
# D205: 1 blank line required between summary line and description (found 0)
# D400: First line should end with a period (not ')')
# D401: First line should be in imperative mood; try rephrasing (found 'Function')
# D403: First word of the first line should be properly capitalized ('Add', not 'add')
pydocstyle:
pydocstyle $(PROJECT) \
--convention=numpy \
--match-dir='^(?!extern).*' \
--match='(?!test_).*\.py' \
--add-ignore=D100,D102,D103,D104,D105,D200,D202,D205,D400,D401,D403,D410
dataset-index:
python dev/datasets/make_dataset_index.py dataset-index
# Note: codespell will pick its options from setup.cfg
codespell:
codespell
# TODO: add test and code quality checks for `examples`