-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
299 lines (236 loc) · 7.87 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
.PHONY: build
CMD:=dopplerr
MODULES:=dopplerr cfgtree
DOCKER_BUILD?=docker build
PORT:=8086
LANGUAGES?=fra,eng
BASEDIR?=dopplerr/tests/vectors/basedir
MAPPING?=tv=Series
OPENSUBTITLES_USERNAME?=username
OPENSUBTITLES_PASSWORD?=password
PUSHOVER_USER?=user
PUSHOVER_TOKEN?=token
all: update-pip frontend-all backend-all
backend-all: dev version style checks frontend-build build dists docker-build test-unit
frontend-all: frontend-dev frontend-build
all-local: dev style checks dists test-unit
all-docker: dev style checks docker-build test-unit
all-dev: frontend-dev backend-dev
release: requirements version readme frontend-build backend-build
bootstrap:
@echo "Please sudo the following command in your environment:"
@echo " sudo -E ./bootstrap-system.sh"
@echo " sudo -E ./setup-pip.sh"
update-pip:
# Freeze the version of pip and pipenv for setup reproductibility
pip3 install -U --user 'pip==9.0.1' 'pipenv==9.0.1' 'setuptools>=36.6.0'
dev: update-pip pipenv-install-dev pip-install-e ln-venv
dev-from-scratch: pipenv-install-dev
pipenv-install-dev:
@echo "Setting up development environment"
pipenv install --dev
pip-install-e:
@echo "Manual pip install -e . because Pipenv+PBR does not behaves perfectly together"
pipenv run pip install -e .
pipenv-install-system-dev:
@echo "Setting up development environment"
pipenv install --dev --system
ln-venv:
@# this target creates a .venv link to your virtual env binaries
@# useful for some editors that does not know how to find the venv automatically
@ln -sf $$(pipenv --venv) .venv
@cd .venv/lib && ln -sf python$$(pipenv run python --version | cut -f2 -d' '|cut -c1-3) python
frontend-dev:
cd frontend ; make dev
frontend-build:
cd frontend ; make build
frontend-run:
cd frontend ; make run
frontend-lint:
cd frontend ; make lint
version:
cd frontend ; make release
install-local:
pipenv install
install-system:
pipenv install --system --skip-lock
style: readme requirements isort autopep8 yapf
isort:
pipenv run isort -y
autopep8:
pipenv run autopep8 --in-place --recursive setup.py $(MODULES)
yapf:
pipenv run yapf --style .yapf --recursive -i $(MODULES)
checks: readme requirements flake8 pylint mypy
sc: readme requirements style checks
flake8:
pipenv run flake8 --enable-extra-whitelist $(MODULES)
pylint:
pipenv run pylint --rcfile=.pylintrc --output-format=colorized $(MODULES)
mypy:
pipenv run mypy --config-file .mypy.ini dopplerr cfgtree
requirements:
pipenv run pipenv_to_requirements
build: readme requirements version dists
readme:
# Only for Pypi, which does not render MarkDown Readme
pandoc --from=markdown --to=rst --output=README.rst README.md
run-local-from-conf:
@echo "Starting dev-log Dopplerr on http://localhost:$(PORT) from config.json ..."
PYTHONASYNCIODEBUG=1 \
pipenv run $(CMD) \
--output-type dev \
--debug-config \
--verbose \
-l "debug.log"
run-local:
@echo "Starting dev-log Dopplerr on http://localhost:$(PORT) ..."
PYTHONASYNCIODEBUG=1 \
pipenv run $(CMD) \
--output-type dev \
--debug-config \
--verbose \
-l "debug.log" \
-p $(PORT) \
-m $(MAPPING) \
-b $(BASEDIR) \
--subliminal-languages $(LANGUAGES) \
--subliminal-opensubtitles-enabled \
--subliminal-opensubtitles-password $(OPENSUBTITLES_PASSWORD) \
--notifications-pushover-enabled \
--notifications-pushover-user $(PUSHOVER_USER) \
--notifications-pushover-token $(PUSHOVER_TOKEN) \
postman-sonarr:
pipenv run curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data "@dopplerr/tests/vectors/sonarr_on_download2.json" \
http://localhost:$(PORT)/api/v1/notify/sonarr
postman: postman-sonarr
run-local-env:
@echo "Starting plain log Dopplerr on http://localhost:$(PORT) "
@echo "using environment variable parameters..."
DOPPLERR_GENERAL_PORT=$(PORT) \
DOPPLERR_VERBOSE=1 \
DOPPLERR_GENERAL_MAPPING="$(MAPPING)" \
DOPPLERR_GENERAL_BASEDIR=$(BASEDIR) \
DOPPLERR_SUBLIMINAL_LANGUAGES=$(LANGUAGES) \
DOPPLERR_SUBLIMINAL_OPENSUBTITLES_ENABLED=$(OPENSUBTITLES_USERNAME) \
DOPPLERR_SUBLIMINAL_OPENSUBTITLES_USER=$(OPENSUBTITLES_USERNAME) \
DOPPLERR_SUBLIMINAL_OPENSUBTITLES_PASSWORD=$(OPENSUBTITLES_PASSWORD) \
DOPPLERR_NOTIFICATIONS_PUSHOVER_ENABLED=$(PUSHOVER_USER) \
DOPPLERR_NOTIFICATIONS_PUSHOVER_USER=$(PUSHOVER_USER) \
DOPPLERR_NOTIFICATIONS_PUSHOVER_TOKEN=$(PUSHOVER_TOKEN) \
pipenv run $(CMD) \
--output-type plain
run-docker: kill-docker
@echo "Starting plain-log Dopplerr on http://localhost:$(PORT) "
docker run -p $(PORT):$(PORT) \
-e "DOPPLERR_VERBOSE=1" \
-e "DOPPLERR_GENERAL_MAPPING='$(MAPPING)'" \
-e "DOPPLERR_GENERAL_LOGFILE=debug.log" \
-e "DOPPLERR_GENERAL_BASEDIR=$(BASEDIR)" \
-e "DOPPLERR_SUBLIMINAL_LANGUAGES=$(LANGUAGES)" \
-e "DOPPLERR_SUBLIMINAL_OPENSUBTITLES_ENABLED=1" \
-e "DOPPLERR_SUBLIMINAL_OPENSUBTITLES_USER=$(OPENSUBTITLES_USERNAME)" \
-e "DOPPLERR_SUBLIMINAL_OPENSUBTITLES_PASSWORD=$(OPENSUBTITLES_PASSWORD)" \
-e "DOPPLERR_NOTIFICATIONS_PUSHOVER_ENABLED=1" \
-e "DOPPLERR_NOTIFICATIONS_PUSHOVER_USER=$(PUSHOVER_USER)" \
-e "DOPPLERR_NOTIFICATIONS_PUSHOVER_TOKEN=$(PUSHOVER_TOKEN)" \
-t dopplerr:latest
run: run-local-from-conf
run_frontend:
cd frontend ; make run
kill-docker:
docker kill $$(docker ps --format '{{.Names}}\t{{.Image}}\t' | grep dopplerr | cut -f1) || true
shell:
@echo "Shell"
pipenv shell
test-unit:
PYTHONASYNCIODEBUG=1 \
pipenv run pytest --junitxml=junit.xml -v $(MODULES)
test-unit-v:
PYTHONASYNCIODEBUG=1 \
pipenv run pytest --junitxml=junit.xml -v -s $(MODULES)
test-v: test-unit-v
docker-build:
@echo "Testing docker build"
@echo "You can change the default 'docker build' command line with the DOCKER_BUILD environment variable"
$(DOCKER_BUILD) -t $(CMD) .
test-coverage:
pipenv run py.test -v --cov ./ --cov-report term-missing
dists: sdist bdist wheels
sdist:
pipenv run python setup.py sdist
bdist:
pipenv run python setup.py bdist
wheels:
@echo "Creating distribution wheel"
pipenv run python setup.py bdist_wheel
pypi-publish: build
@echo "Publishing to Pypy"
pipenv run python setup.py upload -r pypi
update: pipenv-update dev
pipenv-update:
@echo "Updating dependencies..."
pipenv update
pipenv install --dev
@echo "Consider updating 'bootstrap-system.sh' manually"
lock: pipenv-lock dev
pipenv-lock:
pipenv lock
freeze:
pipenv run pip freeze
clean:
pipenv --rm ; true
find . -name '__pycache__' -delete
find . -name "*.pyc" -exec rm -f {} \;
rm -rf cachefile.dbm*
rm -f *.log
rm -f *.log.*
rm -rf .eggs *.egg-info
rm -rf _trial_temp/
rm -rf dist/ build/
rm -rf .venv
# note: keep sqlite.db
clean-db:
rm -f sqlite.db
frontend-clean:
cd frontend ; make clean
clean-all: frontend-clean clean clean-db
githook:style readme version
push: githook
git push origin --all
git push origin --tags
pyannotate:
# do not use for the moment, only python2 annotation are generated.
# Follow: https://github.com/dropbox/pyannotate/issues/4
pipenv run pyannotate -w dopplerr
# aliases to gracefully handle typos on poor dev's terminal
backend-build: build
backend-checks: checks
backend-clean: clean
backend-dev: dev-from-scratch
build-backend: build
build-docker: docker-build
build-frontend: frontend-build
check: checks
dev-backend: dev
dev-frontend: frontend-dev
devel: dev
develop: dev
dist: dists
docker-kill: kill-docker
docker-run: run-docker
docker: docker-build
frontend-run: run-frontend
frontend: frontend-all
image: docker
install: install-system
pypi: pypi-publish
styles: style
test: test-unit
unittest: test-unit
unittests: test-unit
upgrade: update
wheel: wheels