-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
140 lines (118 loc) · 4.48 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
LOCDIR := .
PYHESIVE_DIR = $(addprefix $(LOCDIR)/, pyhesive)
TESTDIR = $(addprefix $(PYHESIVE_DIR)/, test)
PYTHON3 ?= python3
PIP3 ?= $(PYTHON3) -m pip
PYVENV_DIRS := $(addprefix $(LOCDIR)/, venv)
.PHONY: test clean clean-build clean-venv clean-pyc clean-pytest $(PYVENV_DIRS) profile
help:
@printf "Usage: make [MAKE_OPTIONS] [target] (see 'make --help' for MAKE_OPTIONS)\n"
@printf ""
@awk ' \
{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n"; \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)
## -- commonly used --
## install the library from src
install:
-@$(PIP3) install .
## remove generated local files
clean: clean-build clean-venv clean-pyc clean-pytest
## uninstall the package (due to limitations with pip
## does not uninstall dependencies)
uninstall:
-@$(PIP3) uninstall pyhesive
## -- testing --
package: clean
@$(PYTHON3) setup.py sdist bdist_wheel
## upload package to testpypi
test-upload: package
-@$(PYTHON3) -m twine upload --repository testpypi dist/*
## upload package to pypi
upload: package
-@$(PYTHON3) -m twine upload dist/*
create-venv:
-@test -d venv || virtualenv -p $(PYTHON3) venv
## test that package installs cleanly from testpypi and pypi
test-install: create-venv
@echo "==================================================================="
@echo " Installing From TestPyPi"
@echo "==================================================================="
@. $(LOCDIR)/venv/bin/activate && \
$(PIP3) install --upgrade pip setuptools && \
$(PIP3) install --index-url https://test.pypi.org/simple/ --no-deps --upgrade pyhesive && \
$(PIP3) install pyhesive && \
$(PYTHON3) $(TESTDIR)/testPackage.py
@. $(LOCDIR)/venv/bin/activate && \
cd $(LOCDIR)/bin && pyhesive-insert --help > /dev/null && cd - >/dev/null
@echo "==================================================================="
@echo " Installing From PyPi"
@echo "==================================================================="
@. $(LOCDIR)/venv/bin/activate && $(PIP3) install --upgrade pyhesive && \
$(PYTHON3) $(TESTDIR)/testPackage.py
@echo "==================================================================="
@echo " All Install Tests Completed Successfully"
@echo "==================================================================="
vermin:
@vermin ./pyhesive ./bin
## run full test-suite
test: create-venv vermin
@. $(LOCDIR)/venv/bin/activate && \
$(PIP3) install --upgrade pip setuptools && \
$(PIP3) install -e .[test] && \
vermin ./pyhesive ./bin && \
$(PYTHON3) -m pytest $(PYTEST_ARGS)
@echo "==================================================================="
@echo " All Tests Completed Successfully"
@echo "==================================================================="
## -- misc --
clean-pyc:
-find . -name '*.pyc' -exec rm {} +
-find . -name '*.pyo' -exec rm {} +
-find . -name '*~' -exec rm {} +
-find . -name '__pycache__' -exec rm -r {} +
clean-build:
-if [ -d "./build/" ]; then rm -r ./build/; fi
-if [ -d "./dist/" ]; then rm -r ./dist/; fi
-if [ -d "./.eggs/" ]; then rm -r ./.eggs/; fi
-find . -name '*.egg-info' -exec rm -r {} +
-find . -name '*.egg' -exec rm {} +
clean-pytest:
-if [ -d "./.pytest_cache/" ]; then rm -r ./.pytest_cache/; fi
-if [ -e "./.coverage" ]; then rm ./.coverage; fi
clean-venv: $(PYVENV_DIRS)
-if [ -e "./pyvenv.cfg" ]; then rm ./pyvenv.cfg; fi
$(PYVENV_DIRS):
-${RM} -r $@
## install the library in development mode
install-dev:
-@$(PIP3) install -e .[test]
## profile the code
profile:
-@cd $(LOCDIR)/bin && \
$(PYTHON3) -m cProfile -o pyhesive.prof ./pyhesive-insert $(PROFILE_ARGS) && \
snakeviz pyhesive.prof