tests: pylint updates
[git-cola.git] / Makefile
blob919d3bedc29a57963b0ae3d603fbafe6dff8b0a9
1 # The default target of this Makefile is...
2 all::
4 # Development
5 # -----------
6 # make V=1 # generate files; V=1 increases verbosity
7 # make test [flags=...] # run tests; flags=-x fails fast
8 # make test V=2 # V=2 increases test verbosity
9 # make doc # build docs
10 # make flake8 # python style checks
11 # make pylint [color=1] # run pylint; color=1 colorizes output
12 # make pylint3k [color=1] # run python2+3 compatibility checks
13 # make check file=<filename> # run precommit checks on <filename>
14 # make format file=<filename> # run the yapf python formatter on <filename>
15 # make precommit [color=1] # run test, doc, flake8, pylint3k, and pylint
17 # Release Prep
18 # ------------
19 # make pot # update main translation template
20 # make po # merge translations
21 # make mo # generate message files
22 # make i18n # all three of the above
24 # Installation
25 # ------------
26 # make prefix=<path> install
27 # DESTDIR is also supported.
29 # To disable distutil's replacement of "#!/usr/bin/env python" with
30 # the path to the build environment's python, pass USE_ENV_PYTHON=1
31 # when invoking make.
33 # The external commands used by this Makefile are...
34 CTAGS = ctags
35 CP = cp
36 FIND = find
37 FLAKE8 = flake8
38 GIT = git
39 GZIP = gzip
40 LN = ln
41 LN_S = $(LN) -s -f
42 MARKDOWN = markdown
43 MKDIR_P = mkdir -p
44 PIP = pip
45 PYLINT = pylint
46 PYTHON = python
47 PYTEST ?= $(PYTHON) -m pytest
48 RM = rm -f
49 RM_R = rm -fr
50 RMDIR = rmdir
51 TAR = tar
52 YAPF = yapf
54 # Flags
55 # -----
56 ifdef V
57 VERBOSE = --verbose
58 ifeq ($(V),2)
59 TEST_VERBOSE = --verbose
60 endif
61 else
62 QUIET = --quiet
63 endif
65 PYTEST_FLAGS = $(QUIET) $(TEST_VERBOSE)
66 PYTEST_FLAGS += --doctest-modules
68 FLAKE8_FLAGS = $(VERBOSE)
69 FLAKE8_FLAGS += --max-line-length=80
70 FLAKE8_FLAGS += --format=pylint
71 FLAKE8_FLAGS += --doctests
73 PYLINT_FLAGS = --rcfile=.pylintrc
74 PYLINT_FLAGS += --score=no
75 ifdef color
76 PYLINT_FLAGS += --output-format=colorized
77 endif
79 # These values can be overridden on the command-line or via config.mak
80 prefix = $(HOME)
81 bindir = $(prefix)/bin
82 datadir = $(prefix)/share/git-cola
83 coladir = $(datadir)/lib
84 hicolordir = $(prefix)/share/icons/hicolor/scalable/apps
85 # DESTDIR =
87 cola_base := git-cola
88 cola_app_base= $(cola_base).app
89 cola_app = $(CURDIR)/$(cola_app_base)
90 cola_version = $(shell $(PYTHON) bin/git-cola version --brief)
91 cola_dist := $(cola_base)-$(cola_version)
93 SETUP ?= $(PYTHON) setup.py
95 build_args += build
96 ifdef USE_ENV_PYTHON
97 build_args += --use-env-python
98 endif
100 install_args += install
101 install_args += --prefix="$(prefix)"
102 install_args += --force
103 install_args += --install-scripts="$(bindir)"
104 install_args += --record=build/MANIFEST
105 install_args += --install-lib="$(coladir)"
106 ifdef DESTDIR
107 install_args += --root="$(DESTDIR)"
108 export DESTDIR
109 endif
110 export prefix
112 # If NO_VENDOR_LIBS is specified on the command line then pass it to setup.py
113 ifdef NO_VENDOR_LIBS
114 install_args += --no-vendor-libs
115 endif
117 PYTHON_DIRS = cola
118 PYTHON_DIRS += test
120 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
121 ALL_PYTHON_DIRS += extras
123 PYTHON_SOURCES = bin/git-cola
124 PYTHON_SOURCES += bin/git-dag
125 PYTHON_SOURCES += share/git-cola/bin/git-xbase
126 PYTHON_SOURCES += setup.py
128 # User customizations
129 -include config.mak
131 all:: build
132 .PHONY: all
134 build_version:
135 @GIT=$(GIT) ./extras/generate-build-version.sh 2>/dev/null || true
136 .PHONY: build_version
138 build: build_version
139 $(SETUP) $(QUIET) $(VERBOSE) $(build_args)
140 .PHONY: build
142 install: all
143 $(SETUP) $(QUIET) $(VERBOSE) $(install_args)
144 $(MKDIR_P) "$(DESTDIR)$(hicolordir)"
145 $(LN_S) "$(datadir)/icons/git-cola.svg" \
146 "$(DESTDIR)$(hicolordir)/git-cola.svg"
147 $(LN_S) git-cola "$(DESTDIR)$(bindir)/cola"
148 $(RM_R) "$(DESTDIR)$(coladir)/git_cola"*
149 $(RM_R) git_cola.egg-info
151 # Maintainer's dist target
152 dist:
153 $(GIT) archive --format=tar --prefix=$(cola_dist)/ HEAD^{tree} | \
154 $(GZIP) -f -9 - >$(cola_dist).tar.gz
156 doc:
157 $(MAKE) -C share/doc/git-cola all
159 html:
160 $(MAKE) -C share/doc/git-cola html
162 man:
163 $(MAKE) -C share/doc/git-cola man
165 install-doc:
166 $(MAKE) -C share/doc/git-cola install
168 install-html:
169 $(MAKE) -C share/doc/git-cola install-html
171 install-man:
172 $(MAKE) -C share/doc/git-cola install-man
174 uninstall:
175 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
176 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
177 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
178 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
179 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
180 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
181 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-dag.appdata.xml
182 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-cola.appdata.xml
183 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
184 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
185 $(RM_R) "$(DESTDIR)$(prefix)"/share/git-cola
186 $(RM) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES/git-cola.mo
187 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null
188 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/appdata 2>/dev/null
189 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null
190 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null
191 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null
192 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null
193 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null
194 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null
195 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null
196 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null
197 -$(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null
198 -$(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null
199 -$(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null
201 test: all
202 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
204 coverage:
205 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
207 clean:
208 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | xargs -0 rm -f
209 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | xargs -0 rm -rf
210 $(RM_R) build dist tags git-cola.app
211 $(RM_R) share/locale
212 $(MAKE) -C share/doc/git-cola clean
214 tags:
215 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py' -print0 | xargs -0 $(CTAGS) -f tags
217 # Update i18n files
218 i18n:: pot
219 i18n:: po
220 i18n:: mo
222 pot:
223 $(SETUP) build_pot --build-dir=po --no-lang
224 .PHONY: pot
227 $(SETUP) build_pot --build-dir=po
228 .PHONY: po
231 $(SETUP) build_mo --force
232 .PHONY: mo
234 git-cola.app:
235 $(MKDIR_P) $(cola_app)/Contents/MacOS
236 $(MKDIR_P) $(cola_app)/Contents/Resources
237 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
238 $(cola_app)/Contents
239 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
240 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
241 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
242 .PHONY: git-cola.app
244 app-tarball: git-cola.app
245 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
247 # Preview the markdown using "make README.html"
248 %.html: %.md
249 $(MARKDOWN) $< >$@
251 flake8:
252 $(FLAKE8) $(FLAKE8_FLAGS) $(PYTHON_SOURCES) $(PYTHON_DIRS)
254 pylint3k:
255 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
256 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
258 pylint:
259 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
260 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
262 check:
263 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
264 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
265 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
267 # Pre-commit checks
268 precommit:: all
269 precommit:: doc
270 precommit:: test
271 precommit:: flake8
272 precommit:: pylint3k
273 precommit:: pylint
275 format:
276 $(YAPF) --in-place $(flags) $(file)
278 requirements:
279 $(PIP) install --requirement requirements/requirements.txt
281 requirements-dev:
282 $(PIP) install --requirement requirements/requirements-dev.txt