This repository has been archived by the owner on Aug 4, 2018. It is now read-only.
forked from Guake/guake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
330 lines (250 loc) · 9.71 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
.PHONY: build dev
PYTHON_INTERPRETER=python3
MODULE:=guake
INSTALL_ROOT:=/
PREFIX:=$(INSTALL_ROOT)usr/local
DIST_PACKAGE:=$$($(PYTHON_INTERPRETER) -c "import site; import os; print(os.path.basename(site.getsitepackages()[0]))")
OLD_PREFIX:=$(INSTALL_ROOT)usr
SLUG:=fragment_name
default: prepare-install
# 'make' target, so users can install guake without need to install the 'dev' dependencies
prepare-install: generate-desktop generate-mo compile-glib-schemas
reset:
dconf reset -f /apps/guake/
all: clean dev style checks dists test docs
dev: pipenv-install-dev requirements ln-venv setup-githook prepare-install
dev-no-pipenv: clean
virtualenv --python $(PYTHON_INTERPRETER) .venv
. .venv/bin/activate && pip3 install -r requirements.txt -r requirements-dev.txt -e .
pipenv-install-dev:
pipenv install --dev --python $(PYTHON_INTERPRETER); \
ln-venv:
# use that to configure a symbolic link to the virtualenv in .venv
rm -rf .venv
ln -s $$(pipenv --venv) .venv
install-system: install-schemas install-locale
# you probably want to execute this target with sudo:
# sudo make install
@echo "Installing from on your system is not recommended."
@echo "Please prefer you application package manager (apt, yum, ...)"
@pip3 install -r requirements.txt
@$(PYTHON_INTERPRETER) setup.py install --root "$(INSTALL_ROOT)" --optimize=1
@glib-compile-schemas $(PREFIX)/lib/python$(shell $(PYTHON_INTERPRETER) -c "import sys; v = sys.version_info; print('{}.{}'.format(v.major, v.minor))")/$(DIST_PACKAGE)/guake/data/
@update-desktop-database || echo "Could not run update-desktop-database, are you root?"
@rm -rfv build *.egg-info
install-locale:
for f in $$(find po -iname "*.mo"); do \
l="$${f%%.*}"; \
lb=$$(basename $$l); \
install -Dm644 "$$f" "$(PREFIX)/share/locale/$$lb/LC_MESSAGES/guake.mo"; \
done;
uninstall-locale: install-old-locale
find $(PREFIX)/share/locale/ -name "guake.mo" -exec rm -f {} \;
install-old-locale:
@find $(OLD_PREFIX)/share/locale/ -name "guake.mo" -exec rm -f {} \;
install-schemas:
install -Dm644 "guake/data/guake.desktop" "$(PREFIX)/share/applications/guake.desktop"
install -Dm644 "guake/data/guake-prefs.desktop" "$(PREFIX)/share/applications/guake-prefs.desktop"
install -Dm644 "guake/data/pixmaps/guake.png" "$(PREFIX)/share/pixmaps/guake.png"
install -Dm644 "guake/data/org.guake.gschema.xml" "$(PREFIX)/share/glib-2.0/schemas/org.guake.gschema.xml"
glib-compile-schemas $(PREFIX)/share/glib-2.0/schemas/
uninstall-system: uninstall-schemas
@pip uninstall -y guake || true
@rm -f $(PREFIX)/bin/guake
@rm -f $(PREFIX)/bin/guake-prefs
purge-system: uninstall-system reset
uninstall-schemas: uninstall-old-schemas
rm -f "$(PREFIX)/share/applications/guake.desktop"
rm -f "$(PREFIX)/share/applications/guake-prefs.desktop"
rm -f "$(PREFIX)/share/pixmaps/guake.png"
rm -f "$(PREFIX)/share/glib-2.0/schemas/org.guake.gschema.xml"
rm -f $(PREFIX)/lib/python$(shell $(PYTHON_INTERPRETER) -c "import sys; v = sys.version_info; print('{}.{}'.format(v.major, v.minor))")/$(DIST_PACKAGE)/guake/data/schema.guake.gschema.xml
[ -d $(PREFIX)/share/glib-2.0/schemas/ ] && glib-compile-schemas $(PREFIX)/share/glib-2.0/schemas/ || true
uninstall-old-schemas:
@rm -f "$(OLD_PREFIX)/share/applications/guake.desktop"
@rm -f "$(OLD_PREFIX)/share/applications/guake-prefs.desktop"
@rm -f "$(OLD_PREFIX)/share/pixmaps/guake.png"
@rm -f "$(OLD_PREFIX)/share/glib-2.0/schemas/org.guake.gschema.xml"
@rm -f "$(OLD_PREFIX)/share/glib-2.0/schemas/schema.guake.gschema.xml"
@rm -f $(OLD_PREFIX)/lib/python$(shell $(PYTHON_INTERPRETER) -c "import sys; v = sys.version_info; print('{}.{}'.format(v.major, v.minor))")/$(DIST_PACKAGE)/guake/data/schema.guake.gschema.xml
@glib-compile-schemas $(OLD_PREFIX)/share/glib-2.0/schemas/
compile-glib-schemas: clean-schemas
glib-compile-schemas --strict guake/data/
clean-schemas:
rm -f guake/data/gschemas.compiled
style: fiximports autopep8 yapf
fiximports:
@for fil in $$(find setup.py guake -name "*.py"); do \
echo "Sorting imports from: $$fil"; \
pipenv run fiximports $$fil; \
done
autopep8:
pipenv run autopep8 --in-place --recursive setup.py $(MODULE)
yapf:
pipenv run yapf --style .yapf --recursive -i $(MODULE)
checks: flake8 pylint
flake8:
pipenv run python setup.py flake8
pylint:
pipenv run pylint --rcfile=.pylintrc --output-format=colorized $(MODULE)
sc: style check
dists: update-po requirements prepare-install rm-dists sdist bdist wheels
build: dists
sdist:
pipenv run python setup.py sdist
rm-dists:
rm -rf build dist
bdist:
pipenv run python setup.py bdist
wheels:
pipenv run python setup.py bdist_wheel
run-local: compile-glib-schemas
export GUAKE_DATA_DIR=$(shell pwd)/guake/data ; pipenv run ./run-local.sh
shell:
pipenv shell
test:
pipenv run pytest $(MODULE)
test-coverage:
pipenv run py.test -v --cov $(MODULE) --cov-report term-missing
sct: style check test
docs: clean-docs
cd doc && pipenv run make html
tag-pbr:
@{ \
set -e ;\
export VERSION=$$(pipenv run python setup.py --version | cut -d. -f1,2,3); \
echo "I: Computed new version: $$VERSION"; \
echo "I: presse ENTER to accept or type new version number:"; \
read VERSION_OVERRIDE; \
VERSION=$${VERSION_OVERRIDE:-$$VERSION}; \
PROJECTNAME=$$(pipenv run python setup.py --name); \
echo "I: Tagging $$PROJECTNAME in version $$VERSION with tag: $$VERSION" ; \
echo "$$ git tag -s $$VERSION -m \"$$PROJECTNAME $$VERSION\""; \
echo "I: Pushing tag $$VERSION, press ENTER to continue, C-c to interrupt"; \
read _; \
echo "$$ git push origin $$VERSION"; \
}
@# Note:
@# To sign, need gpg configured and the following command:
@# git tag -s $$VERSION -m \"$$PROJECTNAME $$VERSION\""
pypi-publish: build
pipenv run python setup.py upload -r pypi
update:
pipenv update
pipenv install --dev
lock: pipenv-lock requirements
requirements:
pipenv run pipenv_to_requirements
pipenv-lock:
pipenv lock
freeze:
pipenv run pip freeze
githook:
bash git-hooks/post-commit
setup-githook:
rm -f .git/hooks/post-commit
cp -fv git-hooks/* .git/hooks/
push: githook
git push origin --tags
clean: rm-dists clean-docs clean-po clean-schemas clean-py
@echo "clean successful"
clean-py:
@pipenv --rm ; true
@find . -name "*.pyc" -exec rm -f {} \;
@rm -f guake/data/guake-prefs.desktop guake/data/guake.desktop
@rm -rf .venv .eggs *.egg-info po/*.pot
clean-po:
@rm -f po/guake.pot
@find po -name "*.mo" -exec rm -f {} \;
clean-docs:
rm -rf doc/build
update-po:
@find guake -iname "*.py" | xargs xgettext --from-code=UTF-8 --output=guake-python.pot
@find guake/data -iname "*.glade" | xargs xgettext --from-code=UTF-8 \
-L Glade \
--output=guake-glade.pot
@(\
find guake/data -iname "*.desktop" | xargs xgettext --from-code=UTF-8 \
-L Desktop \
--output=guake-desktop.pot \
) || ( \
echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
touch guake-desktop.pot)
@msgcat --use-first guake-python.pot guake-glade.pot guake-desktop.pot > po/guake.pot
@rm guake-python.pot guake-glade.pot guake-desktop.pot
for f in $$(find po -iname "*.po"); do \
echo "updating $$f"; \
msgcat --use-first "$$f" po/guake.pot > "$$f.new"; \
mv "$$f.new" $$f; \
done;
pot: update-po
generate-mo:
@for f in $$(find po -iname "*.po"); do \
echo "generating $$f"; \
l="$${f%%.*}"; \
msgfmt "$$f" -o "$$l.mo"; \
done;
generate-desktop:
@echo "generating desktop files"
@msgfmt --desktop --template=guake/data/guake.template.desktop \
-d po \
-o guake/data/guake.desktop || ( \
echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
cp guake/data/guake.template.desktop guake/data/guake.desktop)
@msgfmt --desktop --template=guake/data/guake-prefs.template.desktop \
-d po \
-o guake/data/guake-prefs.desktop || ( \
echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
cp guake/data/guake-prefs.template.desktop guake/data/guake-prefs.desktop)
reno:
pipenv run reno new $(SLUG) --edit
reno-lint:
pipenv run reno lint
release-note: reno-lint release-note-news release-note-github
release-note-news: reno-lint
@echo "Generating release note for NEWS file"
@pipenv run reno report 2>/dev/null | \
pandoc -f rst -t rst --atx-headers --columns=100 --wrap=auto --tab-stop 2 | \
tr '\n' '\r' | \
sed 's/\r\.\.\ .*\r\r//g' | \
sed 's/\r\-\ \ \r\r\ \ /\r-/g' | \
sed 's/\r\ \ \ \ \ \-\ \ /\r - /g' | \
sed 's/\r\-\ \ /\r- /g' | \
sed -E 's/\r\s{3}([^\s\-])/\r \1/g' | \
sed 's/`\_\_/`_/g' | \
tr '\r' '\n' \
> NEWS.rst
@cat releasenotes/archive/NEWS.pre-3.0 >> NEWS.rst
release-note-github: reno-lint
@echo
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
@echo "!! Generating release note for GitHub !!"
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
@echo "-------- copy / paste from here --------"
@# markdown_github to be avoided => gfm output comes in pandoc 2.0.4 release dec 2017
@pipenv run reno report 2>/dev/null | \
pandoc -f rst -t markdown --atx-headers --wrap=none --tab-stop 2 | \
tr '\n' '\r' | \
sed 's/\r<!-- -->\r//g' | \
sed 's/\r\-\ \r\r\ /\r-/g' | \
sed 's/\r\ \ \:\ \ \ /\r /g' | \
sed 's/\r\r\ \ \ \ \-\ /\r - /g' | \
sed 's/\r\ \ \ \ \-\ /\r - /g' | \
sed 's/\r\ \ >\ \-\ /\r - /g' | \
sed 's/\\\#/\#/g' | \
tr '\r' '\n'
release: dists update-po release-note
# aliases to gracefully handle typos on poor dev's terminal
check: checks
devel: dev
develop: dev
dist: dists
doc: docs
install: install-system
purge: purge-system
pypi: pypi-publish
run: run-local
styles: style
uninstall: uninstall-system
upgrade: update
wheel: wheels