on update_data_update_languages.py help sign in
searx/Makefile
265 lines 7.1 kB history raw
1# -*- coding: utf-8; mode: makefile-gmake -*-
2.DEFAULT_GOAL=help
4include utils/makefile.include
6PYOBJECTS = searx
7DOC = docs
8PY_SETUP_EXTRAS ?= \[test\]
9PYLINT_SEARX_DISABLE_OPTION := I,C,R,W0105,W0212,W0511,W0603,W0613,W0621,W0702,W0703,W1401,E1136
10PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES := supported_languages,language_aliases
12include utils/makefile.python
13include utils/makefile.sphinx
15all: clean install
17PHONY += help-min help-all help
19help: help-min
20 @echo ''
21 @echo 'to get more help: make help-all'
23help-min:
24 @echo ' test - run developer tests'
25 @echo ' docs - build documentation'
26 @echo ' docs-live - autobuild HTML documentation while editing'
27 @echo ' run - run developer instance'
28 @echo ' install - developer install (./local)'
29 @echo ' uninstall - uninstall (./local)'
30 @echo ' gh-pages - build docs & deploy on gh-pages branch'
31 @echo ' clean - drop builds and environments'
32 @echo ' project - re-build generic files of the searx project'
33 @echo ' buildenv - re-build environment files (aka brand)'
34 @echo ' themes - re-build build the source of the themes'
35 @echo ' docker - build Docker image'
36 @echo ' node.env - download & install npm dependencies locally'
37 @echo ''
38 @$(MAKE) -e -s make-help
40help-all: help-min
41 @echo ''
42 @$(MAKE) -e -s python-help
43 @echo ''
44 @$(MAKE) -e -s docs-help
46PHONY += install
47install: buildenv pyenvinstall
49PHONY += uninstall
50uninstall: pyenvuninstall
52PHONY += clean
53clean: pyclean docs-clean node.clean test.clean
54 $(call cmd,common_clean)
56PHONY += run
57run: buildenv pyenvinstall
58 $(Q) ( \
59 sleep 2 ; \
60 xdg-open http://127.0.0.1:8888/ ; \
61 ) &
62 SEARX_DEBUG=1 $(PY_ENV)/bin/python ./searx/webapp.py
64# docs
65# ----
67sphinx-doc-prebuilds:: buildenv pyenvinstall prebuild-includes
69PHONY += docs
70docs: sphinx-doc-prebuilds
71 $(call cmd,sphinx,html,docs,docs)
73PHONY += docs-live
74docs-live: sphinx-doc-prebuilds
75 $(call cmd,sphinx_autobuild,html,docs,docs)
77PHONY += prebuild-includes
78prebuild-includes:
79 $(Q)mkdir -p $(DOCS_BUILD)/includes
80 $(Q)./utils/searx.sh doc | cat > $(DOCS_BUILD)/includes/searx.rst
81 $(Q)./utils/filtron.sh doc | cat > $(DOCS_BUILD)/includes/filtron.rst
82 $(Q)./utils/morty.sh doc | cat > $(DOCS_BUILD)/includes/morty.rst
85$(GH_PAGES)::
86 @echo "doc available at --> $(DOCS_URL)"
88# update project files
89# --------------------
91PHONY += project engines.languages useragents.update buildenv
93project: buildenv useragents.update engines.languages
95engines.languages: pyenvinstall
96 $(Q)echo "fetch languages .."
97 $(Q)$(PY_ENV_ACT); python ./searx_extra/update/update_languages.py
98 $(Q)echo "updated searx/data/engines_languages.json"
99 $(Q)echo "updated searx/languages.py"
101useragents.update: pyenvinstall
102 $(Q)echo "fetch useragents .."
103 $(Q)$(PY_ENV_ACT); python ./searx_extra/update/update_firefox_version.py
104 $(Q)echo "updated searx/data/useragents.json with the most recent versions of Firefox."
106buildenv: pyenv
107 $(Q)$(PY_ENV_ACT); SEARX_DEBUG=1 python utils/build_env.py
109# node / npm
110# ----------
112node.env: buildenv
113 $(Q)./manage.sh npm_packages
115node.clean:
116 $(Q)echo "CLEAN locally installed npm dependencies"
117 $(Q)rm -rf \
118 ./node_modules \
119 ./package-lock.json \
120 ./searx/static/themes/oscar/package-lock.json \
121 ./searx/static/themes/oscar/node_modules \
122 ./searx/static/themes/simple/package-lock.json \
123 ./searx/static/themes/simple/node_modules
125# build themes
126# ------------
128PHONY += themes themes.oscar themes.simple
129themes: buildenv themes.oscar themes.simple
131quiet_cmd_lessc = LESSC $3
132 cmd_lessc = PATH="$$(npm bin):$$PATH" \
133 lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
135quiet_cmd_grunt = GRUNT $2
136 cmd_grunt = PATH="$$(npm bin):$$PATH" \
137 grunt --gruntfile "$2"
139themes.oscar: node.env
140 $(Q)echo '[!] build oscar theme'
141 $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
143themes.simple: node.env
144 $(Q)echo '[!] build simple theme'
145 $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
148# docker
149# ------
151PHONY += docker
152docker: buildenv
153 $(Q)./manage.sh docker_build
155docker.push: buildenv
156 $(Q)./manage.sh docker_build push
158# gecko
159# -----
161PHONY += gecko.driver
162gecko.driver:
163 $(PY_ENV_ACT); ./manage.sh install_geckodriver
165# search.checker
166# --------------
168search.checker: pyenvinstall
169 $(Q)$(PY_ENV_ACT); searx-checker -v
171ENGINE_TARGETS=$(patsubst searx/engines/%.py,search.checker.%,$(wildcard searx/engines/[!_]*.py))
173$(ENGINE_TARGETS): pyenvinstall
174 $(Q)$(PY_ENV_ACT); searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
177# test
178# ----
180PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
181test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
183PYLINT_FILES=\
184 searx/preferences.py \
185 searx/testing.py \
186 searx/engines/gigablast.py \
187 searx/engines/deviantart.py \
188 searx/engines/digg.py \
189 searx/engines/google.py \
190 searx/engines/google_news.py \
191 searx/engines/google_videos.py \
192 searx/engines/google_images.py \
193 searx/engines/mediathekviewweb.py \
194 searx/engines/solidtorrents.py \
195 searx/engines/solr.py \
196 searx/engines/google_scholar.py \
197 searx/engines/yahoo_news.py \
198 searx/engines/apkmirror.py \
199 searx_extra/update/update_external_bangs.py
201test.pylint: pyenvinstall
202 $(call cmd,pylint,$(PYLINT_FILES))
203 $(call cmd,pylint,\
204 --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
205 --additional-builtins=$(PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES) \
206 searx/engines \
207 )
208 $(call cmd,pylint,\
209 --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
210 --ignore=searx/engines \
211 searx tests \
212 )
214# ignored rules:
215# E402 module level import not at top of file
216# W503 line break before binary operator
218# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
219test.sh:
220 shellcheck -x -s bash utils/brand.env
221 shellcheck -x utils/lib.sh
222 shellcheck -x utils/filtron.sh
223 shellcheck -x utils/searx.sh
224 shellcheck -x utils/morty.sh
225 shellcheck -x utils/lxc.sh
226 shellcheck -x utils/lxc-searx.env
227 shellcheck -x .config.sh
229test.pep8: pyenvinstall
230 @echo "TEST pycodestyle (formerly pep8)"
231 $(Q)$(PY_ENV_ACT); pycodestyle --exclude='searx/static, searx/languages.py, $(foreach f,$(PYLINT_FILES),$(f),)' \
232 --max-line-length=120 --ignore "E117,E252,E402,E722,E741,W503,W504,W605" searx tests
234test.unit: pyenvinstall
235 @echo "TEST tests/unit"
236 $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
238test.coverage: pyenvinstall
239 @echo "TEST unit test coverage"
240 $(Q)$(PY_ENV_ACT); \
241 python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
242 && coverage report \
243 && coverage html \
245test.robot: pyenvinstall gecko.driver
246 @echo "TEST robot"
247 $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
249test.clean:
250 @echo "CLEAN intermediate test stuff"
251 $(Q)rm -rf geckodriver.log .coverage coverage/
254# travis
255# ------
257PHONY += ci.test
258ci.test:
259 $(PY_ENV_BIN)/python -c "import yaml" || make clean
260 $(MAKE) test
262travis.codecov:
263 $(Q)$(PY_ENV_BIN)/python -m pip install codecov
265.PHONY: $(PHONY)