-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
156 lines (117 loc) · 5.77 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
145
146
147
148
149
150
151
152
153
154
155
156
.PHONY: clean clean-test clean-pyc clean-build clean-venvs line pep8 docs dist install develop help
.DEFAULT_GOAL := help
CONDA_PACKAGES = qutip
TESTENV =
#TESTENV = MATPLOTLIBRC=tests
TESTOPTIONS = --doctest-modules --cov=newtonprop --nbval --sanitize-with docs/nbval_sanitize.cfg
TESTS = src tests docs/*.rst docs/example.ipynb
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: clean-build clean-pyc clean-test clean-venvs ## remove all build, test, coverage, and Python artifacts, as well as environments
$(MAKE) -C docs clean
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
rm -fr src/*.egg-info
find tests src -name '*.egg-info' -exec rm -fr {} +
find tests src -name '*.egg' -exec rm -f {} +
clean-pyc: ## remove Python file artifacts
find tests src -name '*.pyc' -exec rm -f {} +
find tests src -name '*.pyo' -exec rm -f {} +
find tests src -name '*~' -exec rm -f {} +
find tests src -name '__pycache__' -exec rm -fr {} +
clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/
clean-venvs: ## remove testing/build environments
rm -fr .tox
rm -fr .venv
lint: ## check style with flake8
flake8 src tests
pep8: ## check style with pep8
pep8 src tests
test: test35 test36 ## run tests on every Python version
.venv/py34/bin/py.test:
@conda create -y -m -p .venv/py34 python=3.4
@.venv/py34/bin/pip install -e .[dev]
test34: .venv/py34/bin/py.test ## run tests for Python 3.4
$(TESTENV) $< -v $(TESTOPTIONS) $(TESTS)
.venv/py35/bin/py.test:
@conda create -y -m --override-channels -c defaults -p .venv/py35 python=3.5
@# if the conda installation does not work, simply comment out the following line, and let pip handle it
@conda install -y --override-channels -c defaults -c conda-forge -p .venv/py35 $(CONDA_PACKAGES)
@.venv/py35/bin/pip install -e .[dev]
test35: .venv/py35/bin/py.test ## run tests for Python 3.5
$(TESTENV) $< -v $(TESTOPTIONS) $(TESTS)
.venv/py36/bin/py.test:
@conda create -y -m --override-channels -c defaults -p .venv/py36 python=3.6
@# if the conda installation does not work, simply comment out the following line, and let pip handle it
@conda install -y --override-channels -c defaults -c conda-forge -p .venv/py36 $(CONDA_PACKAGES)
@.venv/py36/bin/pip install -e .[dev]
test36: .venv/py36/bin/py.test ## run tests for Python 3.6
NUMBA_DISABLE_JIT=1 $(TESTENV) $< -v $(TESTOPTIONS) $(TESTS)
.venv/py37/bin/py.test:
@conda create -y -m -p .venv/py37 python=3.7
@# if the conda installation does not work, simply comment out the following line, and let pip handle it
@conda install -y --override-channels -c defaults -c conda-forge -p .venv/py37 $(CONDA_PACKAGES)
@.venv/py37/bin/pip install -e .[dev]
test37: .venv/py37/bin/py.test ## run tests for Python 3.7
NUMBA_DISABLE_JIT=1 $(TESTENV) $< -v $(TESTOPTIONS) src tests $(TESTS)
.venv/py36/bin/sphinx-build: .venv/py36/bin/py.test
docs: .venv/py36/bin/sphinx-build ## generate Sphinx HTML documentation, including API docs
$(MAKE) -C docs SPHINXBUILD=../.venv/py36/bin/sphinx-build clean
NUMBA_DISABLE_JIT=1 $(MAKE) -C docs SPHINXBUILD=../.venv/py36/bin/sphinx-build html
@echo "open docs/_build/html/index.html"
spellcheck: .venv/py36/bin/sphinx-build ## check spelling in docs
@.venv/py36/bin/pip install sphinxcontrib-spelling
SPELLCHECK=en_US $(MAKE) -C docs SPHINXBUILD=../.venv/py36/bin/sphinx-build spelling
coverage: .venv/py36/bin/py.test ## generate coverage report in ./htmlcov
NUMBA_DISABLE_JIT=1 $(TESTENV) $< -v $(TESTOPTIONS) $(TESTS)
.venv/py36/bin/coverage html
@echo "open htmlcov/index.html"
test-release: clean-build clean-pyc dist ## package and upload a release to test.pypi.org
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
release: clean-build clean-pyc dist ## package and upload a release
twine upload dist/*
dist: clean-build clean-pyc ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
install: clean-build clean-pyc ## install the package to the active Python's site-packages
pip install .
uninstall: ## uinstall the package from the active Python's site-packages
pip uninstall newtonprop
develop: clean-build clean-pyc ## install the package to the active Python's site-packages, in develop mode
pip install -e .
develop-test: develop ## run tests within the active Python environment
$(TESTENV) py.test -v $(TESTOPTIONS) $(TESTS)
develop-docs: develop ## generate Sphinx HTML documentation, including API docs, within the active Python environment
$(MAKE) -C docs clean
$(MAKE) -C docs html
@echo "open docs/_build/html/index.html"
.venv/py36/bin/jupyter: .venv/py36/bin/py.test
# How to execute notebook files
%.ipynb.log: %.ipynb .venv/py36/bin/jupyter
@echo ""
@.venv/py36/bin/jupyter nbconvert --to notebook --execute --inplace --allow-errors --ExecutePreprocessor.timeout=300 --ExecutePreprocessor.kernel_name='python3' --config=/dev/null $< 2>&1 | tee $@
NOTEBOOKFILES = $(shell find docs/ -iname '*.ipynb' -maxdepth 1)
NOTEBOOKLOGS = $(patsubst %.ipynb,%.ipynb.log,$(NOTEBOOKFILES))
notebooks: $(NOTEBOOKLOGS) ## re-evaluate the notebooks
@echo ""
@echo "All notebook are now up to date; the were executed using the python3 kernel"
@.venv/py36/bin/jupyter kernelspec list | grep python3
jupyter-notebook: .venv/py36/bin/jupyter ## run a notebook server for editing the examples
.venv/py36/bin/jupyter notebook --config=/dev/null
jupyter-lab: .venv/py36/bin/jupyter ## run a jupyterlab server for editing the examples
@.venv/py36/bin/pip install jupyterlab
.venv/py36/bin/jupyter lab --config=/dev/null