|
| 1 | +.PHONY: help install lint clean test |
| 2 | + |
| 3 | +# You can specify exact version of python3 or venv name as environment variable |
| 4 | +PYTHON_VERSION?=python3.10 |
| 5 | +VENV_NAME?=venv |
| 6 | + |
| 7 | +SRC_DIR=brain |
| 8 | + |
| 9 | +VENV_BIN=$(shell pwd)/${VENV_NAME}/bin |
| 10 | +VENV_ACTIVATE=. $(VENV_NAME)/bin/activate |
| 11 | + |
| 12 | +PYTHON=${VENV_NAME}/bin/python3 |
| 13 | + |
| 14 | + |
| 15 | +.DEFAULT: help |
| 16 | +help: |
| 17 | + @echo "Make file commands:" |
| 18 | + @echo " make install" |
| 19 | + @echo " Prepare complete development environment" |
| 20 | + @echo " make lint" |
| 21 | + @echo " Run pylint and flake8" |
| 22 | + @echo " make test" |
| 23 | + @echo " Run python tests of algorithm" |
| 24 | + @echo " make clean" |
| 25 | + @echo " Clean repository" |
| 26 | + |
| 27 | +install: |
| 28 | +# sudo apt -y install build-essential $(PYTHON_VERSION) $(PYTHON_VERSION)-dev $(PYTHON_VERSION)-distutils |
| 29 | + ${PYTHON_VERSION} -m pip install -U pip |
| 30 | + ${PYTHON_VERSION} -m pip install virtualenv |
| 31 | + make venv |
| 32 | + ${VENV_ACTIVATE}; pre-commit install |
| 33 | + ${PYTHON} -m pip install -e . |
| 34 | + |
| 35 | + |
| 36 | +# Runs when the file changes |
| 37 | +venv: $(VENV_NAME)/bin/activate |
| 38 | +$(VENV_NAME)/bin/activate: requirements.txt requirements-dev.txt |
| 39 | + test -d $(VENV_NAME) || $(PYTHON_VERSION) -m virtualenv -p $(PYTHON_VERSION) $(VENV_NAME) |
| 40 | + ${PYTHON} -m pip install -U pip |
| 41 | + ${PYTHON} -m pip install -r requirements.txt -r requirements-dev.txt |
| 42 | + touch $(VENV_NAME)/bin/activate |
| 43 | + |
| 44 | +clean: |
| 45 | + find . -name '*.pyc' -exec rm --force {} + |
| 46 | + rm -rf $(VENV_NAME) *.eggs *.egg-info dist build docs/_build .cache |
| 47 | + |
| 48 | +test: |
| 49 | + ${PYTHON} -m pytest --cov=$(SRC_DIR) |
| 50 | + |
| 51 | +lint: |
| 52 | + ${PYTHON} -m flake8 --toml-config=pyproject.toml $(SRC_DIR) |
| 53 | + ${PYTHON} -m pylint --rcfile=pyproject.toml $(SRC_DIR) |
0 commit comments