@@ -8,51 +8,12 @@ PACKAGES := $(PACKAGE) tests
8
8
CONFIG := $(wildcard * .py)
9
9
MODULES := $(wildcard $(PACKAGE ) /* .py)
10
10
11
- # Python settings
12
- PYTHON_MAJOR ?= 2
13
- PYTHON_MINOR ?= 7
14
-
15
- # System paths
16
- PLATFORM := $(shell python -c 'import sys; print(sys.platform) ')
17
- ifneq ($(findstring win32, $(PLATFORM ) ) , )
18
- WINDOWS := true
19
- SYS_PYTHON_DIR := C:\\Python$(PYTHON_MAJOR)$(PYTHON_MINOR)
20
- SYS_PYTHON := $(SYS_PYTHON_DIR)\\python.exe
21
- # https://bugs.launchpad.net/virtualenv/+bug/449537
22
- export TCL_LIBRARY=$(SYS_PYTHON_DIR)\\tcl\\tcl8.5
23
- else
24
- ifneq ($(findstring darwin, $(PLATFORM)), )
25
- MAC := true
26
- else
27
- LINUX := true
28
- endif
29
- SYS_PYTHON := python$(PYTHON_MAJOR)
30
- ifdef PYTHON_MINOR
31
- SYS_PYTHON := $(SYS_PYTHON).$(PYTHON_MINOR)
32
- endif
33
- endif
34
-
35
11
# Virtual environment paths
36
- ENV := .venv
37
- ifneq ($(findstring win32, $(PLATFORM ) ) , )
38
- BIN := $(ENV)/Scripts
39
- ACTIVATE := $(BIN)/activate.bat
40
- OPEN := cmd /c start
41
- PYTHON := $(BIN)/python.exe
42
- PIP := $(BIN)/pip.exe
43
- else
44
- BIN := $(ENV)/bin
45
- ACTIVATE := . $(BIN)/activate
46
- ifneq ($(findstring cygwin, $(PLATFORM)), )
47
- OPEN := cygstart
48
- else
49
- OPEN := open
50
- endif
51
- PYTHON := $(BIN)/python
52
- PIP := $(BIN)/pip
53
- endif
12
+ export PIPENV_VENV_IN_PROJECT =true
13
+ export PIPENV_IGNORE_VIRTUALENVS =true
14
+ VENV := .venv
54
15
55
- # MAIN TASKS ###################################################################
16
+ # MAIN TASKS ##################################################################
56
17
57
18
SNIFFER := pipenv run sniffer
58
19
@@ -68,40 +29,21 @@ watch: install .clean-test ## Continuously run all CI tasks when files chanage
68
29
69
30
.PHONY : run # # Start the program
70
31
run : install
71
- $( PYTHON ) $(PACKAGE ) /__main__.py
32
+ pipenv run python $(PACKAGE ) /__main__.py
72
33
73
- # PROJECT DEPENDENCIES #########################################################
34
+ # PROJECT DEPENDENCIES ########################################################
74
35
75
- export PIPENV_SHELL_COMPAT =true
76
- export PIPENV_VENV_IN_PROJECT =true
77
- export PIPENV_IGNORE_VIRTUALENVS =true
78
-
79
- DEPENDENCIES := $(ENV ) /.installed
80
- METADATA := *.egg-info
36
+ DEPENDENCIES := $(VENV ) /.installed
81
37
82
38
.PHONY : install
83
- install : $(DEPENDENCIES ) $( METADATA )
39
+ install : $(DEPENDENCIES )
84
40
85
- $(DEPENDENCIES ) : $(PIP ) Pipfile*
41
+ $(DEPENDENCIES ) : Pipfile* setup.py
42
+ pipenv run python setup.py develop
86
43
pipenv install --dev
87
- ifdef WINDOWS
88
- @ echo "Manually install pywin32: https://sourceforge.net/projects/pywin32/files/pywin32"
89
- else ifdef MAC
90
- $(PIP) install pync MacFSEvents
91
- else ifdef LINUX
92
- $(PIP) install pyinotify
93
- endif
94
- @ touch $@
95
-
96
- $(METADATA ) : $(PYTHON ) setup.py
97
- $(PYTHON ) setup.py develop
98
44
@ touch $@
99
45
100
- $(PYTHON ) $(PIP ) :
101
- pipenv --python=$(SYS_PYTHON )
102
- pipenv run pip --version
103
-
104
- # CHECKS #######################################################################
46
+ # CHECKS ######################################################################
105
47
106
48
FLAKE8 := pipenv run flake8
107
49
@@ -112,11 +54,11 @@ check: flake8 ## Run linters and static analysis
112
54
flake8 : install
113
55
$(FLAKE8 ) flask_api --ignore=E128,E501 --exclude=__init__.py
114
56
115
- # TESTS ########################################################################
57
+ # TESTS #######################################################################
116
58
117
59
NOSE := pipenv run nosetests
118
60
COVERAGE := pipenv run coverage
119
- COVERAGE_SPACE := pipenv run coverage.space
61
+ COVERAGESPACE := pipenv run coveragespace
120
62
121
63
RANDOM_SEED ?= $(shell date +% s)
122
64
@@ -128,20 +70,20 @@ endif
128
70
.PHONY : test
129
71
test : install # # Run unit and integration tests
130
72
$(NOSE ) $(PACKAGE ) $(NOSE_OPTIONS )
131
- $(COVERAGE_SPACE ) $(REPOSITORY ) overall
73
+ $(COVERAGESPACE ) $(REPOSITORY ) overall
132
74
133
75
.PHONY : read-coverage
134
76
read-coverage :
135
- $( OPEN ) coverage /index.html
77
+ open htmlcov /index.html
136
78
137
- # DOCUMENTATION ################################################################
79
+ # DOCUMENTATION ###############################################################
138
80
139
81
MKDOCS := pipenv run mkdocs
140
82
141
83
MKDOCS_INDEX := site/index.html
142
84
143
- .PHONY : doc
144
- doc : mkdocs # # Generate documentation
85
+ .PHONY : docs
86
+ docs : mkdocs # # Generate documentation
145
87
146
88
.PHONY : mkdocs
147
89
mkdocs : install $(MKDOCS_INDEX )
@@ -153,83 +95,59 @@ mkdocs-live: mkdocs
153
95
eval " sleep 3; open http://127.0.0.1:8000" &
154
96
$(MKDOCS ) serve
155
97
156
- # BUILD ########################################################################
98
+ # BUILD #######################################################################
157
99
158
100
DIST_FILES := dist/*.tar.gz dist/*.whl
159
101
160
102
.PHONY : dist
161
103
dist : install $(DIST_FILES )
162
104
$(DIST_FILES ) : $(MODULES )
163
105
rm -f $(DIST_FILES )
164
- $( PYTHON ) setup.py check --restructuredtext --strict --metadata
165
- $( PYTHON ) setup.py sdist
166
- $( PYTHON ) setup.py bdist_wheel
106
+ pipenv run python setup.py check --restructuredtext --strict --metadata
107
+ pipenv run python setup.py sdist
108
+ pipenv run python setup.py bdist_wheel
167
109
168
110
# RELEASE ######################################################################
169
111
170
112
TWINE := pipenv run twine
171
113
172
- .PHONY : register
173
- register : dist # # Register the project on PyPI
174
- @ echo NOTE: your project must be registered manually
175
- @ echo https://github.com/pypa/python-packaging-user-guide/issues/263
176
- # TODO: switch to twine when the above issue is resolved
177
- # $(TWINE) register dist/*.whl
178
-
179
114
.PHONY : upload
180
- upload : .git-no-changes register # # Upload the current version to PyPI
115
+ upload : dist # # Upload the current version to PyPI
116
+ git diff --name-only --exit-code
181
117
$(TWINE ) upload dist/* .*
182
- $(OPEN ) https://pypi.python.org/pypi/$(PROJECT )
183
-
184
- .PHONY : .git-no-changes
185
- .git-no-changes :
186
- @ if git diff --name-only --exit-code; \
187
- then \
188
- echo Git working copy is clean...; \
189
- else \
190
- echo ERROR: Git working copy is dirty! ; \
191
- echo Commit your changes and try again.; \
192
- exit -1; \
193
- fi ;
118
+ open https://pypi.org/project/$(PROJECT )
194
119
195
- # CLEANUP ######################################################################
120
+ # CLEANUP #####################################################################
196
121
197
122
.PHONY : clean
198
- clean : .clean-dist .clean-test .clean-doc .clean-build # # Delete all generated and temporary files
123
+ clean : .clean-build .clean-docs .clean-test .clean-install # # Delete all generated and temporary files
199
124
200
125
.PHONY : clean-all
201
- clean-all : clean .clean-env .clean-workspace
126
+ clean-all : clean
127
+ rm -rf $(VENV )
202
128
203
- .PHONY : .clean-build
204
- .clean-build :
129
+ .PHONY : .clean-install
130
+ .clean-install :
205
131
find $(PACKAGES ) -name ' *.pyc' -delete
206
132
find $(PACKAGES ) -name ' __pycache__' -delete
207
133
rm -rf * .egg-info
208
134
209
- .PHONY : .clean-doc
210
- .clean-doc :
211
- rm -rf README.rst docs/apidocs * .html docs/* .png site
212
-
213
135
.PHONY : .clean-test
214
136
.clean-test :
215
137
rm -rf .cache .pytest .coverage htmlcov xmlreport
216
138
217
- .PHONY : .clean-dist
218
- .clean-dist :
219
- rm -rf * .spec dist build
220
-
221
- .PHONY : .clean-env
222
- .clean-env : clean
223
- rm -rf $(ENV )
139
+ .PHONY : .clean-docs
140
+ .clean-docs :
141
+ rm -rf * .rst docs/apidocs * .html docs/* .png site
224
142
225
- .PHONY : .clean-workspace
226
- .clean-workspace :
227
- rm -rf * .sublime-workspace
143
+ .PHONY : .clean-build
144
+ .clean-build :
145
+ rm -rf * .spec dist build
228
146
229
- # HELP #########################################################################
147
+ # HELP ########################################################################
230
148
231
149
.PHONY : help
232
150
help : all
233
- @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
151
+ @ grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
234
152
235
153
.DEFAULT_GOAL := help
0 commit comments