-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (79 loc) · 2.96 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
THIS_MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
THIS_DIR := $(shell dirname $(THIS_MAKEFILE))
THIS_PROJECT := $(shell basename $(THIS_DIR))
package = $(THIS_PROJECT)
bin = venv/bin
python = $(bin)/python
pip = $(bin)/pip --disable-pip-version-check
pytest = $(bin)/pytest -rxXs --color=auto --full-trace -vvv --tb=short -W ignore::DeprecationWarning --showlocals
setup = $(python) ./setup.py
script = $(package)/$(package)
git = $(shell which git)
.PHONY: all clean requirements.txt venv version
default: help
workspace: venv requirements.txt
buildenv: clean workspace version
all: workspace install
help:
@ echo "Targets available for '$(THIS_PROJECT)':"
@ echo ' all - workspace, install'
@ echo ' clean - Clean the (build) workspace'
@ echo ' install-e - Install $(package) (editable) using pip'
@ echo ' install - Install $(package) using pip'
@ echo ' package - Build the pip package/wheel'
@ echo ' requirements.txt - Update requirements.txt from setup.py'
@ echo ' run - Run $(script)'
@ echo ' show - Show $(package) as installed by pip'
@ echo ' test - Run the test suite for $(package)'
@ echo ' uninstall - Uninstall $(package)'
@ echo ' venv-bootstrap - Satisfy buildenv requirements to create venv/'
@ echo ' venv - Create the venv'
@ echo ' version - Derive the (new) version of $(package)'
@ echo ' workspace - Setup workspace (clean, venv, requirements, ...)'
# Testing workspace
install: workspace show
$(setup) version
$(setup) clean --all
$(pip) install .
# Editable workspace
install-e: buildenv show
$(pip) install -e ./
show:
@ $(pip) list | grep -i $(package)
run:
@ $(python) $(script) -h
@! $(python) $(script)
package: version
$(setup) install sdist bdist_wheel
twine check dist/*
clean:
test -e "$(git)" && $(git) checkout requirements.txt || true
./setup.py clean --all --verbose
@ rm -frv dist/ build/ *.egg-info/ venv/ .*.sw? test*.tap || true
@ find . -depth -type d -iname __pycache__ -exec rm -frv {} +
venv-bootstrap:
@ pip install --upgrade setuptools wheel virtualenv
venv: $(pip) requirements.txt
$(pip):
test -d venv || virtualenv venv/
$(pip) install --upgrade pip setuptools wheel pytest pytest-tap pytest-cov
requirements.txt:
@ test -e "$(git)" && $(git) checkout requirements.txt || true
$(setup) requirements >> requirements.txt
$(pip) install --upgrade --requirement requirements.txt
uninstall:
$(pip) uninstall -y $(package)
version:
ifndef CI_BUILD_REF_NAME
$(warning CI_BUILD_REF_NAME is not set, are we running under gitlab CI?)
$(git) describe --tags > version
else
echo "$$CI_BUILD_REF_NAME" > version
endif
$(setup) version
# @ bin/test-harness $(filter-out $@,$(MAKECMDGOALS))
test: venv/ venv/bin/ venv/bin/pip ./requirements.txt
$(eval args := $(filter-out $@,$(MAKECMDGOALS)))
$(pytest) tests/**/*.py -k "$(args)"
%:
@: