project maintenance

This commit is contained in:
Manuel Barkhau 2020-08-26 21:49:01 +00:00
parent 78760f6324
commit ae35ae3c1c
11 changed files with 213 additions and 84 deletions

View file

@ -13,7 +13,7 @@ SHELL := /bin/bash
PROJECT_DIR := $(notdir $(abspath .))
ifndef DEVELOPMENT_PYTHON_VERSION
DEVELOPMENT_PYTHON_VERSION := python=3.6
DEVELOPMENT_PYTHON_VERSION := python=3.8
endif
ifndef SUPPORTED_PYTHON_VERSIONS
@ -186,18 +186,18 @@ help:
@if [[ ! -f $(DEV_ENV_PY) ]]; then \
echo "Missing python interpreter at $(DEV_ENV_PY) !"; \
echo "You problably want to install first:"; \
echo "You problably want to first setup the virtual environments:"; \
echo ""; \
echo " make install"; \
echo " make conda"; \
echo ""; \
exit 0; \
fi
@if [[ ! -f $(CONDA_BIN) ]]; then \
echo "No conda installation found!"; \
echo "You problably want to install first:"; \
echo "You problably want to first setup the virtual environments:"; \
echo ""; \
echo " make install"; \
echo " make conda"; \
echo ""; \
exit 0; \
fi
@ -281,14 +281,9 @@ force:
rm -rf vendor/__pycache__/
## Setup python virtual environments
.PHONY: install
install: build/deps.txt
## Update dependencies (pip install -U ...)
.PHONY: update
update: build/deps.txt
## Create/Update python virtual environments
.PHONY: conda
conda: build/deps.txt
## Install git pre-push hooks
@ -306,10 +301,8 @@ git_hooks:
lint_isort:
@printf "isort ...\n"
@$(DEV_ENV)/bin/isort \
--check-only \
--force-single-line-imports \
--length-sort \
--recursive \
--check-only \
--line-width=$(MAX_LINE_LEN) \
--project $(MODULE_NAME) \
src/ test/
@ -317,8 +310,8 @@ lint_isort:
## Run sjfmt with --check
.PHONY: lint_sjfmt
lint_sjfmt:
.PHONY: lint_fmt
lint_fmt:
@printf "sjfmt ...\n"
@$(DEV_ENV)/bin/sjfmt \
--target-version=py36 \
@ -355,15 +348,15 @@ lint_pylint:
## Run pylint-ignore --update-ignorefile.
.PHONY: pylint_update_ignorefile
pylint_update_ignorefile:
.PHONY: pylint_ignore
pylint_ignore:
$(DEV_ENV)/bin/pylint-ignore --rcfile=setup.cfg \
src/ test/ --update-ignorefile
## Run flake8 linter and check for fmt
.PHONY: lint
lint: lint_isort lint_sjfmt lint_flake8 lint_pylint
lint: lint_isort lint_fmt lint_flake8 lint_pylint
## Run mypy type checker
@ -420,15 +413,10 @@ test:
@rm -rf "test/__pycache__";
## -- Helpers --
## Run import sorting on src/ and test/
.PHONY: fmt_isort
fmt_isort:
@$(DEV_ENV)/bin/isort \
--force-single-line-imports \
--length-sort \
--recursive \
--line-width=$(MAX_LINE_LEN) \
--project $(MODULE_NAME) \
@ -450,6 +438,9 @@ fmt_sjfmt:
fmt: fmt_isort fmt_sjfmt
## -- Helpers --
## Shortcut for make fmt lint mypy devtest test
.PHONY: check
check: fmt lint mypy devtest test
@ -480,6 +471,7 @@ activate:
@echo 'export ENV=$${ENV-dev};'
@echo 'export PYTHONPATH="src/:vendor/:$$PYTHONPATH";'
@echo 'conda activate $(DEV_ENV_NAME);'
@echo 'function deactivate {'
@echo ' if [[ -z $${_env_before_activate} ]]; then'
@echo ' export ENV=$${_env_before_activate}; '
@ -491,6 +483,8 @@ activate:
@echo ' else'
@echo ' unset PYTHONPATH;'
@echo ' fi'
@echo ' unset _env_before_activate;'
@echo ' unset _pythonpath_before_activate;'
@echo ' conda deactivate;'
@echo '};'