pylint: backwards compatibility
[git-cola.git] / Makefile
blob4f0fb30cdf6528527b671a606ad5494e8c47c705
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 format file=<filename> # run the yapf python formatter on <filename>
14 # make check [color=1] # run test, doc, flake8, pylint3k, and pylint
15 # make check file=<filename> # run checks on <filename>
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 TOX ?= tox
53 YAPF = yapf
55 # Flags
56 # -----
57 ifdef V
58 VERBOSE = --verbose
59 ifeq ($(V),2)
60 TEST_VERBOSE = --verbose
61 VERBOSE_SHORT = -vv
62 else
63 VERBOSE_SHORT = -v
64 endif
65 else
66 QUIET = --quiet
67 endif
69 FLAKE8_FLAGS = $(VERBOSE)
70 FLAKE8_FLAGS += --max-line-length=80
71 FLAKE8_FLAGS += --format=pylint
72 FLAKE8_FLAGS += --doctests
74 PYTEST_FLAGS = $(QUIET) $(TEST_VERBOSE)
75 PYTEST_FLAGS += --doctest-modules
76 uname_S := $(shell uname -s)
77 ifneq ($(uname_S),Linux)
78 PYTEST_FLAGS += --ignore=cola/inotify.py
79 endif
81 TOX_FLAGS = $(VERBOSE_SHORT) --develop --skip-missing-interpreters
82 TOX_ENVS ?= py{27,34,35,36,37},pylint{2,36,37}
84 PYLINT_FLAGS = --rcfile=.pylintrc
85 PYLINT_FLAGS += --score=no
86 ifdef color
87 PYLINT_FLAGS += --output-format=colorized
88 endif
91 # These values can be overridden on the command-line or via config.mak
92 prefix = $(HOME)
93 bindir = $(prefix)/bin
94 datadir = $(prefix)/share/git-cola
95 coladir = $(datadir)/lib
96 hicolordir = $(prefix)/share/icons/hicolor/scalable/apps
97 # DESTDIR =
99 cola_base := git-cola
100 cola_app_base= $(cola_base).app
101 cola_app = $(CURDIR)/$(cola_app_base)
102 cola_version = $(shell $(PYTHON) bin/git-cola version --brief)
103 cola_dist := $(cola_base)-$(cola_version)
105 SETUP ?= $(PYTHON) setup.py
107 build_args += build
108 ifdef USE_ENV_PYTHON
109 build_args += --use-env-python
110 endif
112 install_args += install
113 install_args += --prefix="$(prefix)"
114 install_args += --force
115 install_args += --install-scripts="$(bindir)"
116 install_args += --record=build/MANIFEST
117 install_args += --install-lib="$(coladir)"
118 ifdef DESTDIR
119 install_args += --root="$(DESTDIR)"
120 export DESTDIR
121 endif
122 export prefix
124 # If NO_VENDOR_LIBS is specified on the command line then pass it to setup.py
125 ifdef NO_VENDOR_LIBS
126 install_args += --no-vendor-libs
127 endif
129 PYTHON_DIRS = cola
130 PYTHON_DIRS += test
132 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
133 ALL_PYTHON_DIRS += extras
135 PYTHON_SOURCES = bin/git-cola
136 PYTHON_SOURCES += bin/git-dag
137 PYTHON_SOURCES += share/git-cola/bin/git-xbase
138 PYTHON_SOURCES += setup.py
140 # User customizations
141 -include config.mak
143 all:: build
144 .PHONY: all
146 build_version:
147 @GIT=$(GIT) ./extras/generate-build-version.sh 2>/dev/null || true
148 .PHONY: build_version
150 build: build_version
151 $(SETUP) $(QUIET) $(VERBOSE) $(build_args)
152 .PHONY: build
154 install: all
155 $(SETUP) $(QUIET) $(VERBOSE) $(install_args)
156 $(MKDIR_P) "$(DESTDIR)$(hicolordir)"
157 $(LN_S) "$(datadir)/icons/git-cola.svg" \
158 "$(DESTDIR)$(hicolordir)/git-cola.svg"
159 $(LN_S) git-cola "$(DESTDIR)$(bindir)/cola"
160 $(RM_R) "$(DESTDIR)$(coladir)/git_cola"*
161 $(RM_R) git_cola.egg-info
162 .PHONY: install
164 # Maintainer's dist target
165 dist:
166 $(GIT) archive --format=tar --prefix=$(cola_dist)/ HEAD^{tree} | \
167 $(GZIP) -f -9 - >$(cola_dist).tar.gz
168 .PHONY: dist
170 doc:
171 $(MAKE) -C share/doc/git-cola all
172 .PHONY: doc
174 html:
175 $(MAKE) -C share/doc/git-cola html
176 .PHONY: html
178 man:
179 $(MAKE) -C share/doc/git-cola man
180 .PHONY: man
182 install-doc:
183 $(MAKE) -C share/doc/git-cola install
184 .PHONY: install-doc
186 install-html:
187 $(MAKE) -C share/doc/git-cola install-html
188 .PHONY: install-html
190 install-man:
191 $(MAKE) -C share/doc/git-cola install-man
192 .PHONY: install-man
194 uninstall:
195 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
196 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
197 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
198 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
199 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
200 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
201 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-dag.appdata.xml
202 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-cola.appdata.xml
203 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
204 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
205 $(RM_R) "$(DESTDIR)$(prefix)"/share/git-cola
206 $(RM) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES/git-cola.mo
207 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null
208 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/appdata 2>/dev/null
209 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null
210 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null
211 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null
212 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null
213 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null
214 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null
215 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null
216 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null
217 -$(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null
218 -$(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null
219 -$(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null
220 .PHONY: uninstall
222 test: all
223 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
224 .PHONY: test
226 coverage:
227 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
228 .PHONY: coverage
230 clean:
231 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | xargs -0 rm -f
232 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | xargs -0 rm -rf
233 $(RM_R) build dist tags git-cola.app
234 $(RM_R) share/locale
235 $(MAKE) -C share/doc/git-cola clean
236 .PHONY: clean
238 tags:
239 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py' -print0 | xargs -0 $(CTAGS) -f tags
240 .PHONY: tags
242 # Update i18n files
243 i18n:: pot
244 i18n:: po
245 i18n:: mo
246 .PHONY: i18n
248 pot:
249 $(SETUP) build_pot --build-dir=po --no-lang
250 .PHONY: pot
253 $(SETUP) build_pot --build-dir=po
254 .PHONY: po
257 $(SETUP) build_mo --force
258 .PHONY: mo
260 git-cola.app:
261 $(MKDIR_P) $(cola_app)/Contents/MacOS
262 $(MKDIR_P) $(cola_app)/Contents/Resources
263 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
264 $(cola_app)/Contents
265 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
266 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
267 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
268 .PHONY: git-cola.app
270 app-tarball: git-cola.app
271 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
272 .PHONY: app-tarball
274 # Preview the markdown using "make README.html"
275 %.html: %.md
276 $(MARKDOWN) $< >$@
278 flake8:
279 $(FLAKE8) --version
280 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
281 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS) contrib
282 .PHONY: flake8
284 pylint-version:
285 $(PYLINT) --version
286 .PHONY: pylint-version
288 pylint3k: pylint-version
289 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
290 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
291 .PHONY: pylint3k
293 pylint: pylint-version
294 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
295 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
296 .PHONY: pylint
298 # Pre-commit checks
299 ifdef file
300 check:
301 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
302 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
303 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
304 else
305 check:: all
306 check:: test
307 check:: doc
308 check:: flake8
309 check:: pylint3k
310 check:: pylint
311 endif
312 .PHONY: check
314 format:
315 $(YAPF) --in-place $(flags) $(file)
316 .PHONY: format
318 requirements:
319 $(PIP) install --requirement requirements/requirements.txt
320 .PHONY: requirements
322 requirements-dev:
323 $(PIP) install --requirement requirements/requirements-dev.txt
324 .PHONY: requirements-dev
326 tox:
327 $(TOX) $(TOX_FLAGS) $(flags)
328 .PHONY: tox
330 tox-check:
331 $(TOX) $(TOX_FLAGS) -e "$(TOX_ENVS)" $(flags)
332 .PHONY: tox-check