VENV ?= venv
ACTIVATE = $(VENV)/bin/activate

.PHONY: deps
deps: $(ACTIVATE)

$(ACTIVATE): requirements.txt requirements-dev.txt
    python3 -m venv $(VENV)
    . $(ACTIVATE) ; pip install -U setuptools wheel
    . $(ACTIVATE) ; pip install -U -r requirements.txt -r requirements-dev.txt
    @touch $(@)

.PHONY: check
check: deps
    . $(ACTIVATE) ; mypy --ignore-missing-imports $(wildcard *.py)
    . $(ACTIVATE) ; flake8 --max-line-length 120 $(wildcard *.py)

.PHONY: clean
clean:
    rm -rf $(VENV) .mypy_cache
    find . -depth -type d -name '__pycache__' -exec rm -rf {} \;