1- .PHONY : all
2- all : clean test bump-patch build publish-module
1+ GLOBAL_PY := python3
2+ BUILD_VENV ?= .build_venv
3+ BUILD_PY := $(BUILD_VENV ) /bin/python
34
45.PHONY : init
5- init :
6- python3 -m pip install tox black pip-tools wheel twine bumpversion
7- python3 -m piptools compile
8- python3 -m pip install -rrequirements.txt
6+ init : $(BUILD_VENV )
7+
8+ $(BUILD_VENV ) :
9+ $(GLOBAL_PY ) -m venv $(BUILD_VENV )
10+ $(BUILD_PY ) -m pip install -U pip
11+
12+ # ##
13+ # Development
14+ # #
915
1016.PHONY : format
11- format :
12- python3 -m black .
17+ format : $( BUILD_VENV ) /bin/black
18+ $( BUILD_PY ) -m black .
1319
1420.PHONY : test
15- test :
16- python3 -m tox -p auto
21+ test : $(BUILD_VENV ) /bin/tox
22+ $(BUILD_PY ) -m tox -p auto -o
23+
24+ .PHONY : upgrade-deps
25+ upgrade-deps : $(BUILD_VENV ) /bin/pip-compile
26+ $(BUILD_VENV ) /bin/pip-compile -U
27+
28+ # ##
29+ # Releases
30+ # #
31+
32+ .PHONY : bump-version-patch
33+ bump-version-patch : $(BUILD_VENV ) /bin/bump2version is-git-clean
34+ $(BUILD_VENV ) /bin/bump2version patch
35+
36+ .PHONY : bump-version-minor
37+ bump-version-minor : $(BUILD_VENV ) /bin/bump2version is-git-clean
38+ $(BUILD_VENV ) /bin/bump2version minor
39+
40+ .PHONY : bump-version-major
41+ bump-version-major : $(BUILD_VENV ) /bin/bump2version is-git-clean
42+ $(BUILD_VENV ) /bin/bump2version major
43+
44+ .PHONY : build
45+ build : $(BUILD_VENV ) /bin/setuptools $(BUILD_VENV ) /bin/twine $(BUILD_VENV ) /bin/wheel is-git-clean format test
46+ $(BUILD_PY ) setup.py sdist bdist_wheel
47+
48+ .PHONY : publish
49+ publish : $(BUILD_VENV ) /bin/twine
50+ username=$$(op read op://Dataspeilet/pypi-upload-token/username ) && \
51+ password=$$(op read op://Dataspeilet/pypi-upload-token/credential ) && \
52+ $(BUILD_PY ) -m twine upload -u $$ username -p $$ password dist/*
1753
1854.PHONY : is-git-clean
1955is-git-clean :
@@ -31,16 +67,12 @@ clean:
3167 rm -rf * .egg-info
3268 rm -rf .tox
3369
34- .PHONY : bump-patch
35- bump-patch : is-git-clean
36- bumpversion patch
70+ # ##
71+ # Python build dependencies
72+ # #
3773
38- .PHONY : build
39- build :
40- python3 setup.py sdist bdist_wheel
74+ $(BUILD_VENV ) /bin/pip-compile : $(BUILD_VENV )
75+ $(BUILD_PY ) -m pip install -U pip-tools
4176
42- .PHONY : publish-module
43- publish-module :
44- username=$$(op read op://Dataspeilet/pypi-upload-token/username ) && \
45- password=$$(op read op://Dataspeilet/pypi-upload-token/credential ) && \
46- python -m twine upload -u $$ username -p $$ password dist/*
77+ $(BUILD_VENV ) /bin/% : $(BUILD_VENV )
78+ $(BUILD_PY ) -m pip install -U $*
0 commit comments