|
| 1 | +VIRTUALENV = virtualenv --python=python3 |
| 2 | + |
| 3 | +VENV := $(shell echo $${VIRTUAL_ENV-.venv}) |
| 4 | +PYTHON = $(VENV)/bin/python |
| 5 | + |
| 6 | +INSTALL_STAMP = $(VENV)/.install.stamp |
| 7 | +DEV_STAMP = $(VENV)/.dev_env_installed.stamp |
| 8 | +TEMPDIR := $(shell mktemp -du) |
| 9 | + |
| 10 | +help: |
| 11 | + @echo "Please use 'make <target>' where <target> is one of" |
| 12 | + @echo " format reformat code: black and isort" |
| 13 | + @echo " install install dependencies and prepare environment" |
| 14 | + @echo " install-dev install dependencies and everything needed to run tests" |
| 15 | + @echo " black run the black tool, which will automatically reformat the code" |
| 16 | + @echo " isort run the isort tool, which will automatically sort all of the imports" |
| 17 | + @echo " clean remove *.pyc files and __pycache__ directory" |
| 18 | + @echo " distclean remove *.egg-info files and *.egg, build and dist directories" |
| 19 | + @echo " maintainer-clean remove the .tox and the .venv directories" |
| 20 | + @echo "Check the Makefile to know exactly what each target is doing." |
| 21 | + |
| 22 | +virtualenv: $(PYTHON) |
| 23 | +$(PYTHON): |
| 24 | + $(VIRTUALENV) $(VENV) |
| 25 | + |
| 26 | +install: $(INSTALL_STAMP) |
| 27 | +$(INSTALL_STAMP): $(PYTHON) setup.py requirements.txt |
| 28 | + $(VENV)/bin/pip install -U pip |
| 29 | + $(VENV)/bin/pip install -Ue . -c requirements.txt |
| 30 | + touch $(INSTALL_STAMP) |
| 31 | + |
| 32 | +install-dev: $(INSTALL_STAMP) $(DEV_STAMP) |
| 33 | +$(DEV_STAMP): $(PYTHON) dev-requirements.txt |
| 34 | + $(VENV)/bin/pip install -Ur dev-requirements.txt |
| 35 | + touch $(DEV_STAMP) |
| 36 | + |
| 37 | +format: black isort |
| 38 | + |
| 39 | +black: install-dev |
| 40 | + $(VENV)/bin/black setup.py alma |
| 41 | + |
| 42 | +isort: install-dev |
| 43 | + $(VENV)/bin/isort --recursive setup.py alma |
| 44 | + |
| 45 | +build-requirements: |
| 46 | + $(VIRTUALENV) $(TEMPDIR) |
| 47 | + $(TEMPDIR)/bin/pip install -U pip |
| 48 | + $(TEMPDIR)/bin/pip install -Ue . |
| 49 | + $(TEMPDIR)/bin/pip freeze | grep -v -- '-e' > requirements.txt |
| 50 | + |
| 51 | +clean: |
| 52 | + find . -name '__pycache__' -type d | xargs rm -fr |
| 53 | + |
| 54 | +distclean: clean |
| 55 | + rm -fr *.egg *.egg-info/ dist/ build/ |
| 56 | + |
| 57 | +maintainer-clean: distclean |
| 58 | + rm -fr .venv/ .tox/ |
0 commit comments