Skip to content

Commit

Permalink
Document Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauko Quiroga committed Aug 25, 2021
1 parent 6b3e1d3 commit 84a13c1
Showing 1 changed file with 54 additions and 28 deletions.
82 changes: 54 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,60 @@
## Same as `make test`.
all: test

uninstall:
pip freeze | grep -v "^-e" | xargs pip uninstall -y

## Install project dependencies.
install:
pip install --upgrade pip twine wheel
pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver

clean:
rm -rf build dist
find . -name '*.pyc' -exec rm \{\} \;

check-syntax-errors:
python -m compileall -q .

check-types:
mypy openfisca_core && mypy openfisca_web_api

check-style:
@# Do not analyse .gitignored files.
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
flake8 `git ls-files | grep "\.py$$"`

format-style:
@# Do not analyse .gitignored files.
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
autopep8 `git ls-files | grep "\.py$$"`

@echo [⚙] Installing dependencies...
@pip install --upgrade pip twine wheel
@pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver

## Install openfisca-core for deployment and publishing.
build: setup.py
@## This allows us to be sure tests are run against the packaged version
@## of openfisca-core, the same we put in the hands of users and reusers.
@echo [⚙] Building and installing locally built openfisca-core...
@python $? bdist_wheel
@find dist -name "*.whl" -exec pip install --force-reinstall {}[dev] \;

## Uninstall project dependencies.
uninstall:
@echo [⚙] Uninstalling project dependencies...
@pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y

## Delete builds and compiled python files.
clean: \
$(shell ls -d * | grep "build\|dist") \
$(shell find . -name "*.pyc")
@echo [⚙] Deleting builds and compiled python files...
@rm -rf $?

## Compile python files to check for syntax errors.
check-syntax-errors: .
@echo [⚙] Compiling python files to check for syntax errors...
@python -m compileall -q $?

## Run linters to check for syntax and style errors.
check-style: $(shell git ls-files "*.py")
@echo [⚙] Running linters to check for syntax and style errors...
@flake8 $?

## Run code formatters to correct style errors.
format-style: $(shell git ls-files "*.py")
@echo [⚙] Running code formatters to correct style errors...
@autopep8 $?

## Run static type checkers for type errors.
check-types: openfisca_core openfisca_web_api
@echo [⚙] Running static type checkers for type errors...
@mypy $?

## Run openfisca-core tests.
test: clean check-syntax-errors check-style check-types
env PYTEST_ADDOPTS="$$PYTEST_ADDOPTS --cov=openfisca_core" pytest
@echo [⚙] Running openfisca-core tests...
@env PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov=openfisca_core" pytest

## Serve the openfisca Web API.
api:
openfisca serve --country-package openfisca_country_template --extensions openfisca_extension_template
@echo [⚙] Serving the openfisca Web API...
@openfisca serve \
--country-package openfisca_country_template \
--extensions openfisca_extension_template

0 comments on commit 84a13c1

Please sign in to comment.