generated from BastiTee/python-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
109 lines (90 loc) · 2.78 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Required executables
ifeq (, $(shell which python))
$(error "No python on PATH.")
endif
PIPENV_COM := python -m pipenv
ifeq (, $(shell $(PIPENV_COM)))
$(error "Pipenv not available in Python installation.")
endif
# Suppress warning if pipenv is started inside .venv
export PIPENV_VERBOSITY = 1
# Use relative .venv folder instead of home-folder based
export PIPENV_VENV_IN_PROJECT = 1
# Ignore existing venvs
export PIPENV_IGNORE_VIRTUALENVS = 1
# Make sure we are running with an explicit encoding
export LC_ALL = C
export LANG = C.UTF-8
# Set configuration folder to venv
export PYPE_CONFIG_FOLDER = $(shell pwd)/.venv/.pype-cli
# Process variables
VERSION = $(shell python setup.py --version)
PY_FILES := setup.py akai_mpkmini_mkii_ctrl tests
LAST_VERSION := $(shell git tag | sort --version-sort -r | head -n1)
VERSION_HASH := $(shell git show-ref -s $(LAST_VERSION))
all: clean venv build
venv: clean
@echo Initialize virtualenv, i.e., install required packages etc.
$(PIPENV_COM) install --dev
shell:
@echo Initialize virtualenv and open a new shell using it
pipenv shell
clean:
@echo Clean project base
find . -type d \
-name ".venv" -o \
-name ".tox" -o \
-name ".ropeproject" -o \
-name ".mypy_cache" -o \
-name ".pytest_cache" -o \
-name "__pycache__" -o \
-iname "*.egg-info" -o \
-name "build" -o \
-name "dist" \
|xargs rm -rfv
find . -type f \
-name "pyproject.toml" -o \
-name "Pipfile.lock" \
|xargs rm -rfv
test:
@echo Run all tests in default virtualenv
pipenv run py.test tests
testall:
@echo Run all tests against all virtualenvs defined in tox.ini
pipenv run tox -c setup.cfg tests
isort:
@echo Check for incorrectly sorted imports
pipenv run isort --check-only $(PY_FILES)
isort-apply:
@echo Check for incorrectly sorted imports
pipenv run isort $(PY_FILES)
mypy:
@echo Run static code checks against source code base
pipenv run mypy akai_mpkmini_mkii_ctrl
pipenv run mypy tests
lint:
@echo Run code formatting checks against source code base
pipenv run flake8 akai_mpkmini_mkii_ctrl tests
build: test mypy isort lint
@echo Run setup.py-based build process to package application
pipenv run python setup.py bdist_wheel
install: all
@echo Install application
pip install --upgrade --user dist/*.whl
run:
@echo Execute akai_mpkmini_mkii_ctrl directly
pipenv run python -m akai_mpkmini_mkii_ctrl
publish: all
@echo Publish pype to pypi.org
pipenv run twine upload dist/*
release:
@echo Commit release - requires NEXT_VERSION to be set
test $(NEXT_VERSION)
sed -i '' "s/version='[0-9\.]*',/version='$(NEXT_VERSION)',/" setup.py
git commit -am "Release $(NEXT_VERSION)"
git tag $(NEXT_VERSION)
git push origin $(NEXT_VERSION)
git push
changelog:
@echo Return changelog since last version tag
git --no-pager log --pretty=format:"- %s" $(VERSION_HASH)..HEAD |cat