on automatic-update-data help sign in
searx/Makefile
263 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 utils/fetch_languages.py
98 $(Q)echo "update searx/data/engines_languages.json"
99 $(Q)mv engines_languages.json searx/data/engines_languages.json
100 $(Q)echo "update searx/languages.py"
101 $(Q)mv languages.py searx/languages.py
103useragents.update: pyenvinstall
104 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
105 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
107buildenv: pyenv
108 $(Q)$(PY_ENV_ACT); SEARX_DEBUG=1 python utils/build_env.py
110# node / npm
111# ----------
113node.env: buildenv
114 $(Q)./manage.sh npm_packages
116node.clean:
117 $(Q)echo "CLEAN locally installed npm dependencies"
118 $(Q)rm -rf \
119 ./node_modules \
120 ./package-lock.json \
121 ./searx/static/themes/oscar/package-lock.json \
122 ./searx/static/themes/oscar/node_modules \
123 ./searx/static/themes/simple/package-lock.json \
124 ./searx/static/themes/simple/node_modules
126# build themes
127# ------------
129PHONY += themes.bootstrap themes themes.oscar themes.simple
130themes: buildenv themes.bootstrap themes.oscar themes.simple
132quiet_cmd_lessc = LESSC $3
133 cmd_lessc = PATH="$$(npm bin):$$PATH" \
134 lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
136quiet_cmd_grunt = GRUNT $2
137 cmd_grunt = PATH="$$(npm bin):$$PATH" \
138 grunt --gruntfile "$2"
140themes.oscar: node.env
141 $(Q)echo '[!] build oscar theme'
142 $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
144themes.simple: node.env
145 $(Q)echo '[!] build simple theme'
146 $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
148themes.bootstrap: node.env
149 $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
152# docker
153# ------
155PHONY += docker
156docker: buildenv
157 $(Q)./manage.sh docker_build
159docker.push: buildenv
160 $(Q)./manage.sh docker_build push
162# gecko
163# -----
165PHONY += gecko.driver
166gecko.driver:
167 $(PY_ENV_ACT); ./manage.sh install_geckodriver
169# search.checker
170# --------------
172search.checker: pyenvinstall
173 $(Q)$(PY_ENV_ACT); searx-checker -v
175ENGINE_TARGETS=$(patsubst searx/engines/%.py,search.checker.%,$(wildcard searx/engines/[!_]*.py))
177$(ENGINE_TARGETS): pyenvinstall
178 $(Q)$(PY_ENV_ACT); searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
181# test
182# ----
184PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
185test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
187PYLINT_FILES=\
188 searx/preferences.py \
189 searx/testing.py \
190 searx/engines/gigablast.py \
191 searx/engines/deviantart.py \
192 searx/engines/digg.py \
193 searx/engines/google.py \
194 searx/engines/google_news.py \
195 searx/engines/google_videos.py \
196 searx/engines/google_images.py \
197 searx/engines/mediathekviewweb.py
199test.pylint: pyenvinstall
200 $(call cmd,pylint,$(PYLINT_FILES))
201 $(call cmd,pylint,\
202 --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
203 --additional-builtins=$(PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES) \
204 searx/engines \
205 )
206 $(call cmd,pylint,\
207 --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
208 --ignore=searx/engines \
209 searx tests \
210 )
212# ignored rules:
213# E402 module level import not at top of file
214# W503 line break before binary operator
216# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
217test.sh:
218 shellcheck -x -s bash utils/brand.env
219 shellcheck -x utils/lib.sh
220 shellcheck -x utils/filtron.sh
221 shellcheck -x utils/searx.sh
222 shellcheck -x utils/morty.sh
223 shellcheck -x utils/lxc.sh
224 shellcheck -x utils/lxc-searx.env
225 shellcheck -x .config.sh
227test.pep8: pyenvinstall
228 @echo "TEST pycodestyle (formerly pep8)"
229 $(Q)$(PY_ENV_ACT); pycodestyle --exclude='searx/static, searx/languages.py, $(foreach f,$(PYLINT_FILES),$(f),)' \
230 --max-line-length=120 --ignore "E117,E252,E402,E722,E741,W503,W504,W605" searx tests
232test.unit: pyenvinstall
233 @echo "TEST tests/unit"
234 $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
236test.coverage: pyenvinstall
237 @echo "TEST unit test coverage"
238 $(Q)$(PY_ENV_ACT); \
239 python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
240 && coverage report \
241 && coverage html \
243test.robot: pyenvinstall gecko.driver
244 @echo "TEST robot"
245 $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
247test.clean:
248 @echo "CLEAN intermediate test stuff"
249 $(Q)rm -rf geckodriver.log .coverage coverage/
252# travis
253# ------
255PHONY += ci.test
256ci.test:
257 $(PY_ENV_BIN)/python -c "import yaml" || make clean
258 $(MAKE) test
260travis.codecov:
261 $(Q)$(PY_ENV_BIN)/python -m pip install codecov
263.PHONY: $(PHONY)