-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
84 lines (66 loc) · 2.73 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
define help
Supported targets: prepare, develop, sdist, clean, test, and pypi.
The 'prepare' target installs Epitome's build requirements into the current virtualenv.
The 'develop' target creates an editable install of Epitome and its runtime requirements in the
current virtualenv. The install is called 'editable' because changes to the source code
immediately affect the virtualenv.
The 'clean' target undoes the effect of 'develop'.
The 'test' target runs Epitome's unit tests. Set the 'tests' variable to run a particular test, e.g.
make test tests=epitome/test/models_test.py:test
The 'pypi' target publishes the current commit of Epitome to PyPI after enforcing that the working
copy and the index are clean, and tagging it as an unstable .dev build.
endef
export help
help:
@printf "$$help"
SHELL=bash
python=python
pip=pip
tests=epitome
extras=
epitome_version:=$(shell $(python) version.py)
sdist_name:=epitome-$(epitome_version).tar.gz
current_commit:=$(shell git log --pretty=oneline -n 1 -- $(pwd) | cut -f1 -d " ")
dirty:=$(shell (git diff --exit-code && git diff --cached --exit-code) > /dev/null || printf -- --DIRTY)
green=\033[0;32m
normal=\033[0m\n
red=\033[0;31m
prepare:
$(pip) install -r requirements.txt
develop:
$(pip) install -e .$(extras)
clean_develop:
- $(pip) uninstall -y epitome
- rm -rf src/*.egg-info
sdist: dist/$(sdist_name)
dist/$(sdist_name):
@test -f dist/$(sdist_name) && mv dist/$(sdist_name) dist/$(sdist_name).old || true
$(python) setup.py sdist bdist_egg
@test -f dist/$(sdist_name).old \
&& ( cmp -s <(tar -xOzf dist/$(sdist_name)) <(tar -xOzf dist/$(sdist_name).old) \
&& mv dist/$(sdist_name).old dist/$(sdist_name) \
&& printf "$(green)No significant changes to sdist, reinstating backup.$(normal)" \
|| rm dist/$(sdist_name).old ) \
|| true
clean_sdist:
- rm -rf dist
sdist:
clean: clean_develop clean_pypi
check_build_reqs:
@$(python) -c 'import pytest' \
|| ( printf "$(redpip)Build requirements are missing. Run 'make prepare' to install them.$(normal)" ; false )
test: check_build_reqs
$(python) -m pytest -o junit_family=xunit2 -vv --junitxml target/pytest-reports/tests.xml $(tests)
check_clean_working_copy:
@printf "$(green)Checking if your working copy is clean ...$(normal)"
@git diff --exit-code > /dev/null \
|| ( printf "$(red)Your working copy looks dirty.$(normal)" ; false )
@git diff --cached --exit-code > /dev/null \
|| ( printf "$(red)Your index looks dirty.$(normal)" ; false )
pypi: clean clean_sdist check_clean_working_copy
set -x \
&& $(python) setup.py egg_info sdist bdist_egg \
&& twine check dist/* \
&& twine upload dist/*
clean_pypi:
- rm -rf build/