|
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$$"` |
| 8 | + @$(call doc,$@:) |
| 9 | + @pip install --upgrade pip setuptools wheel |
| 10 | + @pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver |
29 | 11 |
|
| 12 | +## Recreate a clean slate locally. |
| 13 | +uninstall: |
| 14 | + @## Trying out packages, building openfisca, etc., can make tests fail. |
| 15 | + @## This task uninstalls everything, including packages in editable mode. |
| 16 | + @$(call doc,$@:) |
| 17 | + pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y |
| 18 | + |
| 19 | +## Delete builds and compiled python files. |
| 20 | +clean: \ |
| 21 | + $(shell ls -d * | grep "build\|dist") \ |
| 22 | + $(shell find . -name "*.pyc") |
| 23 | + @$(call doc,$@:) |
| 24 | + @rm -rf $? |
| 25 | + |
| 26 | +## Run linters to check for syntax and style errors. |
| 27 | +check-style: $(shell git ls-files "*.py") |
| 28 | + @$(call doc,$@:) |
| 29 | + @flake8 $? |
| 30 | + |
| 31 | +## Run code formatters to correct style errors. |
| 32 | +format-style: $(shell git ls-files "*.py") |
| 33 | + @$(call doc,$@:) |
| 34 | + @autopep8 $? |
| 35 | + |
| 36 | +## Run static type checkers for type errors. |
| 37 | +check-types: openfisca_core openfisca_web_api |
| 38 | + @$(call doc,$@:) |
| 39 | + @mypy $? |
| 40 | + |
| 41 | +## Run openfisca-core tests. |
30 | 42 | test: clean check-syntax-errors check-style check-types |
31 | | - env PYTEST_ADDOPTS="$$PYTEST_ADDOPTS --cov=openfisca_core" pytest |
| 43 | + @$(call doc,$@:) |
| 44 | + @PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov=openfisca_core" pytest |
32 | 45 |
|
| 46 | +## Serve the openfisca Web API. |
33 | 47 | api: |
34 | | - openfisca serve --country-package openfisca_country_template --extensions openfisca_extension_template |
| 48 | + @$(call doc,$@:) |
| 49 | + @openfisca serve --country-package openfisca_country_template --extensions openfisca_extension_template |
0 commit comments