|
1 | | -all: test |
| 1 | +doc = sed -n "/^$1/ { x ; p ; } ; s/\#\#/[⚙]/ ; s/\./.../ ; x" ${MAKEFILE_LIST} |
2 | 2 |
|
3 | | -uninstall: |
4 | | - pip freeze | grep -v "^-e" | xargs pip uninstall -y |
| 3 | +## Same as `make test. |
| 4 | +all: test |
5 | 5 |
|
| 6 | +## Install project dependencies. |
6 | 7 | install: |
7 | | - pip install --upgrade pip twine wheel |
8 | | - pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver |
9 | | - |
10 | | -clean: |
11 | | - rm -rf build dist |
12 | | - find . -name '*.pyc' -exec rm \{\} \; |
13 | | - |
14 | | -check-syntax-errors: |
15 | | - python -m compileall -q . |
16 | | - |
17 | | -check-types: |
18 | | - mypy openfisca_core && mypy openfisca_web_api |
19 | | - |
20 | | -check-style: |
21 | | - @# Do not analyse .gitignored files. |
22 | | - @# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764. |
23 | | - flake8 `git ls-files | grep "\.py$$"` |
24 | | - |
25 | | -format-style: |
26 | | - @# Do not analyse .gitignored files. |
27 | | - @# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764. |
28 | | - autopep8 `git ls-files | grep "\.py$$"` |
29 | | - |
| 8 | + @$(call doc,$@:) |
| 9 | + @pip install --upgrade pip twine wheel |
| 10 | + @pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver |
| 11 | + |
| 12 | +## Install openfisca-core for deployment and publishing. |
| 13 | +build: setup.py |
| 14 | + @## This allows us to be sure tests are run against the packaged version |
| 15 | + @## of openfisca-core, the same we put in the hands of users and reusers. |
| 16 | + @$(call doc,$@:) |
| 17 | + @python $? bdist_wheel |
| 18 | + @find dist -name "*.whl" -exec pip install --force-reinstall {}[dev] \; |
| 19 | + |
| 20 | +## Uninstall project dependencies. |
| 21 | +uninstall: |
| 22 | + @$(call doc,$@:) |
| 23 | + @pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y |
| 24 | + |
| 25 | +## Delete builds and compiled python files. |
| 26 | +clean: \ |
| 27 | + $(shell ls -d * | grep "build\|dist") \ |
| 28 | + $(shell find . -name "*.pyc") |
| 29 | + @$(call doc,$@:) |
| 30 | + @rm -rf $? |
| 31 | + |
| 32 | +## Compile python files to check for syntax errors. |
| 33 | +check-syntax-errors: . |
| 34 | + @$(call doc,$@:) |
| 35 | + @python -m compileall -q $? |
| 36 | + |
| 37 | +## Run linters to check for syntax and style errors. |
| 38 | +check-style: $(shell git ls-files "*.py") |
| 39 | + @$(call doc,$@:) |
| 40 | + @flake8 $? |
| 41 | + |
| 42 | +## Run code formatters to correct style errors. |
| 43 | +format-style: $(shell git ls-files "*.py") |
| 44 | + @$(call doc,$@:) |
| 45 | + @autopep8 $? |
| 46 | + |
| 47 | +## Run static type checkers for type errors. |
| 48 | +check-types: openfisca_core openfisca_web_api |
| 49 | + @$(call doc,$@:) |
| 50 | + @mypy $? |
| 51 | + |
| 52 | +## Run openfisca-core tests. |
30 | 53 | test: clean check-syntax-errors check-style check-types |
31 | | - env PYTEST_ADDOPTS="$$PYTEST_ADDOPTS --cov=openfisca_core" pytest |
| 54 | + @$(call doc,$@:) |
| 55 | + @env PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov=openfisca_core" pytest |
32 | 56 |
|
| 57 | +## Serve the openfisca Web API. |
33 | 58 | api: |
34 | | - openfisca serve --country-package openfisca_country_template --extensions openfisca_extension_template |
| 59 | + @$(call doc,$@:) |
| 60 | + @openfisca serve \ |
| 61 | + --country-package openfisca_country_template \ |
| 62 | + --extensions openfisca_extension_template |
0 commit comments