on master help sign in
[mod] replace makefile boilerplate by 'manage' script

Replaces the make targets with the bash scripts Signed-off-by: Markus Heiser <markus@darmarit.de>

commitf55babc23c55bd21206940a18484cf708af57aa5 authorMarkus Heiser <markus@darmarit.de> dateMon 22 Feb 2021, 20:22 (6 years ago) parentf7b9406
12 files changed+107−1058
.github/workflows/data-update.yml+1−2 .github/workflows/integration.yml+4−3 Makefile+78−237 docs/conf.py+1−7 docs/user/conf.py−21 manage+12−17 manage.sh−205 utils/makefile.include+10−49 utils/makefile.python−269 utils/makefile.sphinx−199 utils/searx.sh+1−1 utils/site-python/sphinx_build_tools.py−48
.github/workflows/data-update.yml+1−2
@@ -40,8 +40,7 @@ jobs:
4040 env:
4141 FETCH_SCRIPT: ./searx_extra/update/${{ matrix.fetch }}
4242 run: |
43− source local/py3/bin/activate
44− $FETCH_SCRIPT
43+ V=1 manage pyenv.cmd python "$FETCH_SCRIPT"
4544
4645 - name: Create Pull Request
4746 id: cpr
.github/workflows/integration.yml+4−3
@@ -59,7 +59,7 @@ jobs:
5959 - name: Install node dependencies
6060 run: make V=1 node.env
6161 - name: Build themes
62− run: make V=1 themes
62+ run: make V=1 themes.all
6363
6464 documentation:
6565 name: Documentation
@@ -77,14 +77,15 @@ jobs:
7777 python-version: '3.9'
7878 architecture: 'x64'
7979 - name: Build documentation
80− run: SEARX_DEBUG=1 make V=1 ci-gh-pages
80+ run: |
81+ make V=1 docs.clean docs.html
8182 - name: Deploy
8283 if: github.ref == 'refs/heads/master'
8384 uses: JamesIves/github-pages-deploy-action@3.7.1
8485 with:
8586 GITHUB_TOKEN: ${{ github.token }}
8687 BRANCH: gh-pages
87− FOLDER: build/gh-pages
88+ FOLDER: dist/docs
8889 CLEAN: true # Automatically remove deleted files from the deploy branch
8990
9091 dockers:
Makefile+78−237
@@ -1,266 +1,107 @@
11# -*- coding: utf-8; mode: makefile-gmake -*-
2+# SPDX-License-Identifier: AGPL-3.0-or-later
3+
24.DEFAULT_GOAL=help
5+export MTOOLS=./manage
36
47include utils/makefile.include
58
6−PYOBJECTS = searx
7−DOC = docs
8−PY_SETUP_EXTRAS ?= \[test\]
9−PYLINT_SEARX_DISABLE_OPTION := I,C,R,W0105,W0212,W0511,W0603,W0613,W0621,W0702,W0703,W1401,E1136
10−PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES := supported_languages,language_aliases
11−
12−include utils/makefile.python
13−include utils/makefile.sphinx
14−
159all: clean install
1610
17−PHONY += help-min help-all help
18−
19−help: help-min
20− @echo ''
21− @echo 'to get more help: make help-all'
22−
23−help-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
39−
40−help-all: help-min
41− @echo ''
42− @$(MAKE) -e -s python-help
43− @echo ''
44− @$(MAKE) -e -s docs-help
11+PHONY += help
4512
46−PHONY += install
47−install: buildenv pyenvinstall
13+help:
14+ @./manage --help
15+ @echo '----'
16+ @echo 'run - run developer instance'
17+ @echo 'install - developer install of searx into virtualenv'
18+ @echo 'uninstall - uninstall developer installation'
19+ @echo 'clean - clean up working tree'
20+ @echo 'search.checker - check search engines'
21+ @echo 'test - run shell & CI tests'
22+ @echo 'test.sh - test shell scripts'
23+ @echo 'ci.test - run CI tests'
4824
49−PHONY += uninstall
50−uninstall: pyenvuninstall
51−
52−PHONY += clean
53−clean: pyclean docs-clean node.clean test.clean
54− $(call cmd,common_clean)
5525
5626PHONY += run
57−run: buildenv pyenvinstall
27+run: install
5828 $(Q) ( \
5929 sleep 2 ; \
6030 xdg-open http://127.0.0.1:8888/ ; \
6131 ) &
62− SEARX_DEBUG=1 $(PY_ENV)/bin/python ./searx/webapp.py
63−
64−# docs
65−# ----
66−
67−sphinx-doc-prebuilds:: buildenv pyenvinstall prebuild-includes
68−
69−PHONY += docs
70−docs: sphinx-doc-prebuilds
71− $(call cmd,sphinx,html,docs,docs)
72−
73−PHONY += docs-live
74−docs-live: sphinx-doc-prebuilds
75− $(call cmd,sphinx_autobuild,html,docs,docs)
76−
77−PHONY += prebuild-includes
78−prebuild-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
83−
84−
85−$(GH_PAGES)::
86− @echo "doc available at --> $(DOCS_URL)"
87−
88−# update project files
89−# --------------------
90−
91−PHONY += project engines.languages useragents.update buildenv
92−
93−project: buildenv useragents.update engines.languages
94−
95−engines.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"
100−
101−useragents.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."
105−
106−buildenv: pyenv
107− $(Q)$(PY_ENV_ACT); SEARX_DEBUG=1 python utils/build_env.py
108−
109−# node / npm
110−# ----------
111−
112−node.env: buildenv
113− $(Q)./manage.sh npm_packages
32+ SEARX_DEBUG=1 ./manage pyenv.cmd python ./searx/webapp.py
11433
115−node.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
34+PHONY += install uninstall
35+install uninstall:
36+ $(Q)./manage pyenv.$@
12437
125−# build themes
126−# ------------
127−
128−PHONY += themes themes.oscar themes.simple
129−themes: buildenv themes.oscar themes.simple
130−
131−quiet_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"
134−
135−quiet_cmd_grunt = GRUNT $2
136− cmd_grunt = PATH="$$(npm bin):$$PATH" \
137− grunt --gruntfile "$2"
138−
139−themes.oscar: node.env
140− $(Q)echo '[!] build oscar theme'
141− $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
142−
143−themes.simple: node.env
144− $(Q)echo '[!] build simple theme'
145− $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
146−
147−
148−# docker
149−# ------
150−
151−PHONY += docker
152−docker: buildenv
153− $(Q)./manage.sh docker_build
154−
155−docker.push: buildenv
156− $(Q)./manage.sh docker_build push
157−
158−# gecko
159−# -----
160−
161−PHONY += gecko.driver
162−gecko.driver:
163− $(PY_ENV_ACT); ./manage.sh install_geckodriver
164−
165−# search.checker
166−# --------------
167−
168−search.checker: pyenvinstall
169− $(Q)$(PY_ENV_ACT); searx-checker -v
170−
171−ENGINE_TARGETS=$(patsubst searx/engines/%.py,search.checker.%,$(wildcard searx/engines/[!_]*.py))
172−
173−$(ENGINE_TARGETS): pyenvinstall
174− $(Q)$(PY_ENV_ACT); searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
175−
176−
177−# test
178−# ----
179−
180−PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
181−test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
182−
183−PYLINT_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/meilisearch.py \
195− searx/engines/solidtorrents.py \
196− searx/engines/solr.py \
197− searx/engines/google_scholar.py \
198− searx/engines/yahoo_news.py \
199− searx/engines/apkmirror.py \
200− searx_extra/update/update_external_bangs.py
201−
202−test.pylint: pyenvinstall
203− $(call cmd,pylint,$(PYLINT_FILES))
204− $(call cmd,pylint,\
205− --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
206− --additional-builtins=$(PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES) \
207− searx/engines \
208− )
209− $(call cmd,pylint,\
210− --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
211− --ignore=searx/engines \
212− searx tests \
213− )
38+PHONY += clean
39+clean: py.clean docs.clean node.clean test.clean
40+ $(Q)./manage build_msg CLEAN "common files"
41+ $(Q)find . -name '*.orig' -exec rm -f {} +
42+ $(Q)find . -name '*.rej' -exec rm -f {} +
43+ $(Q)find . -name '*~' -exec rm -f {} +
44+ $(Q)find . -name '*.bak' -exec rm -f {} +
45+
46+PHONY += search.checker search.checker.%
47+search.checker: install
48+ $(Q)./manage pyenv.cmd searx-checker -v
49+
50+search.checker.%: install
51+ $(Q)./manage pyenv.cmd searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
52+
53+PHONY += ci.test test test.sh
54+ci.test: test.pep8 test.pylint test.unit test.robot
55+test: ci.test
56+test.sh:
57+ $(Q)shellcheck -x -s bash \
58+ utils/brand.env \
59+ ./manage \
60+ utils/lib.sh \
61+ utils/filtron.sh \
62+ utils/searx.sh \
63+ utils/morty.sh \
64+ utils/lxc.sh \
65+ utils/lxc-searx.env \
66+ .config.sh
67+ $(Q)./manage build_msg TEST "$@ OK"
21468
215−# ignored rules:
216−# E402 module level import not at top of file
217−# W503 line break before binary operator
21869
219−# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
220−test.sh:
221− shellcheck -x -s bash utils/brand.env
222− shellcheck -x utils/lib.sh
223− shellcheck -x utils/filtron.sh
224− shellcheck -x utils/searx.sh
225− shellcheck -x utils/morty.sh
226− shellcheck -x utils/lxc.sh
227− shellcheck -x utils/lxc-searx.env
228− shellcheck -x .config.sh
70+# wrap ./manage script
22971
230−test.pep8: pyenvinstall
231− @echo "TEST pycodestyle (formerly pep8)"
232− $(Q)$(PY_ENV_ACT); pycodestyle --exclude='searx/static, searx/languages.py, $(foreach f,$(PYLINT_FILES),$(f),)' \
233− --max-line-length=120 --ignore "E117,E252,E402,E722,E741,W503,W504,W605" searx tests
72+MANAGE += buildenv
73+MANAGE += babel.compile
74+MANAGE += data.all data.languages data.useragents
75+MANAGE += docs.html docs.live docs.gh-pages docs.prebuild docs.clean
76+MANAGE += docker.build docker.push
77+MANAGE += gecko.driver
78+MANAGE += node.env node.clean
79+MANAGE += py.build py.clean
80+MANAGE += pyenv pyenv.install pyenv.uninstall
81+MANAGE += pypi.upload pypi.upload.test
82+MANAGE += test.pylint test.pep8 test.unit test.coverage test.robot test.clean
83+MANAGE += themes.all themes.oscar themes.simple themes.bootstrap
23484
235−test.unit: pyenvinstall
236− @echo "TEST tests/unit"
237− $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
85+PHONY += $(MANAGE)
23886
239−test.coverage: pyenvinstall
240− @echo "TEST unit test coverage"
241− $(Q)$(PY_ENV_ACT); \
242− python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
243− && coverage report \
244− && coverage html \
87+$(MANAGE):
88+ $(Q)$(MTOOLS) $@
24589
246−test.robot: pyenvinstall gecko.driver
247− @echo "TEST robot"
248− $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
90+# deprecated
24991
250−test.clean:
251− @echo "CLEAN intermediate test stuff"
252− $(Q)rm -rf geckodriver.log .coverage coverage/
92+PHONY += docs docs-clean docs-live docker themes
25393
94+docs: docs.html
95+ $(Q)./manage build_msg WARN $@ is deprecated use docs.html
25496
255−# travis
256−# ------
97+docs-clean: docs.clean
98+ $(Q)./manage build_msg WARN $@ is deprecated use docs.clean
25799
258−PHONY += ci.test
259−ci.test:
260− $(PY_ENV_BIN)/python -c "import yaml" || make clean
261− $(MAKE) test
100+docs-live: docs.live
101+ $(Q)./manage build_msg WARN $@ is deprecated use docs.live
262102
263−travis.codecov:
264− $(Q)$(PY_ENV_BIN)/python -m pip install codecov
103+docker: docker.build
104+ $(Q)./manage build_msg WARN $@ is deprecated use docker.build
265105
266−.PHONY: $(PHONY)
106+themes: themes.all
107+ $(Q)./manage build_msg WARN $@ is deprecated use themes.all
docs/conf.py+1−7
@@ -1,7 +1,7 @@
11# -*- coding: utf-8 -*-
2+# SPDX-License-Identifier: AGPL-3.0-or-later
23
34import sys, os
4−from sphinx_build_tools import load_sphinx_config
55from pallets_sphinx_themes import ProjectLink
66
77from searx import brand
@@ -128,9 +128,3 @@ html_show_sourcelink = False
128128latex_documents = [
129129 (master_doc, "searx-{}.tex".format(VERSION_STRING), html_title, author, "manual")
130130]
131−
132−# ------------------------------------------------------------------------------
133−# Since loadConfig overwrites settings from the global namespace, it has to be
134−# the last statement in the conf.py file
135−# ------------------------------------------------------------------------------
136−load_sphinx_config(globals())
docs/user/conf.pydeleted−21
@@ -1,21 +0,0 @@
1−# -*- coding: utf-8; mode: python -*-
2−"""Configuration for the Searx user handbook
3−"""
4−project = 'Searx User-HB'
5−version = release = VERSION_STRING
6−
7−intersphinx_mapping['searx'] = (brand.DOCS_URL, None)
8−
9−# Grouping the document tree into LaTeX files. List of tuples
10−# (source start file, target name, title,
11−# author, documentclass [howto, manual, or own class]).
12−latex_documents = [
13− ('index' # startdocname
14− , 'searx-user-hb.tex' # targetname
15− , '' # take title from .rst
16− , author # author
17− , 'howto' # documentclass
18− , False # toctree_only
19− ),
20−]
21−
manage+12−17
@@ -29,6 +29,13 @@ PYLINT_FILES=(
2929 searx/engines/google_videos.py
3030 searx/engines/google_images.py
3131 searx/engines/mediathekviewweb.py
32+ searx/engines/meilisearch.py
33+ searx/engines/solidtorrents.py
34+ searx/engines/solr.py
35+ searx/engines/google_scholar.py
36+ searx/engines/yahoo_news.py
37+ searx/engines/apkmirror.py
38+ searx_extra/update/update_external_bangs.py
3239)
3340
3441PYLINT_SEARX_DISABLE_OPTION="\
@@ -84,7 +91,6 @@ themes.* :
8491 all : build all themes
8592 oscar : build oscar theme
8693 simple : build simple theme
87− bootstrap : less compile bootstrap.min.css CSS
8894EOF
8995}
9096
@@ -114,18 +120,18 @@ data.all() {
114120 data.languages
115121 data.useragents
116122 build_msg DATA "update searx/data/ahmia_blacklist.txt"
117− pyenv.cmd python utils/fetch_ahmia_blacklist.py
123+ pyenv.cmd python searx_extra/update/update_ahmia_blacklist.py
118124 build_msg DATA "update searx/data/wikidata_units.json"
119− pyenv.cmd python utils/fetch_wikidata_units.py
125+ pyenv.cmd python searx_extra/update/update_wikidata_units.py
120126 build_msg DATA "update searx/data/currencies.json"
121− pyenv.cmd python utils/fetch_currencies.py
127+ pyenv.cmd python searx_extra/update/update_currencies.py
122128}
123129
124130
125131data.languages() {
126132 ( set -e
127133 build_msg ENGINES "fetch languages .."
128− pyenv.cmd python utils/fetch_languages.py
134+ pyenv.cmd python searx_extra/update/update_languages.py
129135 build_msg ENGINES "update update searx/languages.py"
130136 build_msg DATA "update searx/data/engines_languages.json"
131137 )
@@ -134,7 +140,7 @@ data.languages() {
134140
135141data.useragents() {
136142 build_msg DATA "update searx/data/useragents.json"
137− pyenv.cmd python utils/fetch_firefox_version.py
143+ pyenv.cmd python searx_extra/update/update_firefox_version.py
138144 dump_return $?
139145}
140146
@@ -347,7 +353,6 @@ pyenv.install() {
347353 return 0
348354 fi
349355 ( set -e
350− py.clean > /dev/null
351356 pyenv
352357 build_msg PYENV "[install] pip install -e 'searx${PY_SETUP_EXTRAS}'"
353358 "${PY_ENV_BIN}/python" -m pip install -e ".${PY_SETUP_EXTRAS}"
@@ -443,7 +448,6 @@ themes.all() {
443448 node.env
444449 themes.oscar
445450 themes.simple
446− themes.bootstrap
447451 )
448452 dump_return $?
449453}
@@ -462,15 +466,6 @@ themes.simple() {
462466 dump_return $?
463467}
464468
465−themes.bootstrap() {
466− build_msg LESSC "searx/static/css/bootstrap.min.css"
467− PATH="$(npm bin):$PATH" lessc \
468− --clean-css="--s1 --advanced --compatibility=ie9" \
469− "searx/static/less/bootstrap/bootstrap.less" \
470− "searx/static/css/bootstrap.min.css"
471− dump_return $?
472−}
473−
474469# shellcheck disable=SC2119
475470main() {
476471
manage.shdeleted−205
@@ -1,205 +0,0 @@
1−#!/bin/sh
2−
3−export LANG=C
4−
5−BASE_DIR="$(dirname -- "`readlink -f -- "$0"`")"
6−
7−cd -- "$BASE_DIR"
8−set -e
9−
10−# subshell
11−PYTHONPATH="$BASE_DIR"
12−SEARX_DIR="$BASE_DIR/searx"
13−ACTION="$1"
14−
15−. "${BASE_DIR}/utils/brand.env"
16−
17−#
18−# Python
19−#
20−
21−update_packages() {
22− pip install --upgrade pip
23− pip install --upgrade setuptools
24− pip install -Ur "$BASE_DIR/requirements.txt"
25−}
26−
27−update_dev_packages() {
28− update_packages
29− pip install -Ur "$BASE_DIR/requirements-dev.txt"
30−}
31−
32−install_geckodriver() {
33− echo '[!] Checking geckodriver'
34− # TODO : check the current geckodriver version
35− set -e
36− geckodriver -V > /dev/null 2>&1 || NOTFOUND=1
37− set +e
38− if [ -z "$NOTFOUND" ]; then
39− return
40− fi
41− GECKODRIVER_VERSION="v0.28.0"
42− PLATFORM="`python3 -c "import platform; print(platform.system().lower(), platform.architecture()[0])"`"
43− case "$PLATFORM" in
44− "linux 32bit" | "linux2 32bit") ARCH="linux32";;
45− "linux 64bit" | "linux2 64bit") ARCH="linux64";;
46− "windows 32 bit") ARCH="win32";;
47− "windows 64 bit") ARCH="win64";;
48− "mac 64bit") ARCH="macos";;
49− esac
50− GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
51−
52− if [ -z "$1" ]; then
53− if [ -z "$VIRTUAL_ENV" ]; then
54− printf "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n %s" "$GECKODRIVER_URL"
55− exit
56− else
57− GECKODRIVER_DIR="$VIRTUAL_ENV/bin"
58− fi
59− else
60− GECKODRIVER_DIR="$1"
61− mkdir -p -- "$GECKODRIVER_DIR"
62− fi
63−
64− printf "Installing %s/geckodriver from\n %s" "$GECKODRIVER_DIR" "$GECKODRIVER_URL"
65−
66− FILE="`mktemp`"
67− wget -qO "$FILE" -- "$GECKODRIVER_URL" && tar xz -C "$GECKODRIVER_DIR" -f "$FILE" geckodriver
68− rm -- "$FILE"
69− chmod 777 -- "$GECKODRIVER_DIR/geckodriver"
70−}
71−
72−locales() {
73− pybabel compile -d "$SEARX_DIR/translations"
74−}
75−
76−
77−#
78−# Web
79−#
80−
81−npm_path_setup() {
82− which npm || (printf 'Error: npm is not found\n'; exit 1)
83− export PATH="$(npm bin)":$PATH
84−}
85−
86−npm_packages() {
87− npm_path_setup
88−
89− echo '[!] install NPM packages'
90− cd -- "$BASE_DIR"
91− npm install less@2.7 less-plugin-clean-css grunt-cli
92−
93− echo '[!] install NPM packages for oscar theme'
94− cd -- "$BASE_DIR/searx/static/themes/oscar"
95− npm install
96−
97− echo '[!] install NPM packages for simple theme'
98− cd -- "$BASE_DIR/searx/static/themes/simple"
99− npm install
100−}
101−
102−docker_build() {
103− # Check if it is a git repository
104− if [ ! -d .git ]; then
105− echo "This is not Git repository"
106− exit 1
107− fi
108−
109− if [ ! -x "$(which git)" ]; then
110− echo "git is not installed"
111− exit 1
112− fi
113−
114− if [ ! git remote get-url origin 2> /dev/null ]; then
115− echo "there is no remote origin"
116− exit 1
117− fi
118−
119− # This is a git repository
120−
121− # "git describe" to get the Docker version (for example : v0.15.0-89-g0585788e)
122− # awk to remove the "v" and the "g"
123− SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); if ($3) { $3=substr($3, 2); } print}')
124−
125− # add the suffix "-dirty" if the repository has uncommited change
126− # /!\ HACK for searx/searx: ignore utils/brand.env
127− git update-index -q --refresh
128− if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'utils/brand.env')" ]; then
129− SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
130− fi
131−
132− # Get the last git commit id, will be added to the Searx version (see Dockerfile)
133− VERSION_GITCOMMIT=$(echo $SEARX_GIT_VERSION | cut -d- -f2-4)
134− echo "Last commit : $VERSION_GITCOMMIT"
135−
136− # Check consistency between the git tag and the searx/version.py file
137− # /!\ HACK : parse Python file with bash /!\
138− # otherwise it is not possible build the docker image without all Python dependencies ( version.py loads __init__.py )
139− # SEARX_PYTHON_VERSION=$(python3 -c "import six; import searx.version; six.print_(searx.version.VERSION_STRING)")
140− SEARX_PYTHON_VERSION=$(cat searx/version.py | grep "\(VERSION_MAJOR\|VERSION_MINOR\|VERSION_BUILD\) =" | cut -d\= -f2 | sed -e 's/^[[:space:]]*//' | paste -sd "." -)
141− if [ $(echo "$SEARX_GIT_VERSION" | cut -d- -f1) != "$SEARX_PYTHON_VERSION" ]; then
142− echo "Inconsistency between the last git tag and the searx/version.py file"
143− echo "git tag: $SEARX_GIT_VERSION"
144− echo "searx/version.py: $SEARX_PYTHON_VERSION"
145− exit 1
146− fi
147−
148− # define the docker image name
149− GITHUB_USER=$(echo "${GIT_URL}" | sed 's/.*github\.com\/\([^\/]*\).*/\1/')
150− SEARX_IMAGE_NAME="${SEARX_IMAGE_NAME:-${GITHUB_USER:-searx}/searx}"
151−
152− # build Docker image
153− echo "Building image ${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}"
154− sudo docker build \
155− --build-arg GIT_URL="${GIT_URL}" \
156− --build-arg SEARX_GIT_VERSION="${SEARX_GIT_VERSION}" \
157− --build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \
158− --build-arg LABEL_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
159− --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \
160− --build-arg LABEL_VCS_URL="${GIT_URL}" \
161− --build-arg TIMESTAMP_SETTINGS=$(git log -1 --format="%cd" --date=unix -- searx/settings.yml) \
162− --build-arg TIMESTAMP_UWSGI=$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini) \
163− -t ${SEARX_IMAGE_NAME}:latest -t ${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION} .
164−
165− if [ "$1" = "push" ]; then
166− sudo docker push ${SEARX_IMAGE_NAME}:latest
167− sudo docker push ${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}
168− fi
169−}
170−
171−#
172−# Help
173−#
174−
175−help() {
176− [ -z "$1" ] || printf 'Error: %s\n' "$1"
177− echo "Searx manage.sh help
178−
179−Commands
180−========
181− help - This text
182−
183− Build requirements
184− ------------------
185− update_packages - Check & update production dependency changes
186− update_dev_packages - Check & update development and production dependency changes
187− install_geckodriver - Download & install geckodriver if not already installed (required for robot_tests)
188− npm_packages - Download & install npm dependencies
189−
190− Build
191− -----
192− locales - Compile locales
193−
194−Environment:
195− GIT_URL: ${GIT_URL}
196− ISSUE_URL: ${ISSUE_URL}
197− SEARX_URL: ${SEARX_URL}
198− DOCS_URL: ${DOCS_URL}
199− PUBLIC_INSTANCES: ${PUBLIC_INSTANCES}
200−"
201−}
202−
203−[ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
204− && help "action not found" \
205− || "$ACTION" "$2"
utils/makefile.include+10−49
@@ -1,4 +1,5 @@
11# -*- coding: utf-8; mode: makefile-gmake -*-
2+# SPDX-License-Identifier: AGPL-3.0-or-later
23
34ifeq (,$(wildcard /.lxcenv.mk))
45PHONY += lxc-activate lxc-purge
@@ -10,60 +11,26 @@ else
1011 include /.lxcenv.mk
1112endif
1213
14+PHONY += make-help
1315ifeq (,$(wildcard /.lxcenv.mk))
1416make-help:
1517else
1618make-help: lxc-help
1719endif
20+ @echo 'options:'
1821 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1922 @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
2023
21−quiet_cmd_common_clean = CLEAN $@
22− cmd_common_clean = \
23− find . -name '*.orig' -exec rm -f {} + ;\
24− find . -name '*.rej' -exec rm -f {} + ;\
25− find . -name '*~' -exec rm -f {} + ;\
26− find . -name '*.bak' -exec rm -f {} + ;\
27−
28−FMT = cat
29−ifeq ($(shell which fmt >/dev/null 2>&1; echo $$?), 0)
30−FMT = fmt
31−endif
32−
33−# MS-Windows
34−#
35−# For a minimal *make-environment*, I'am using the gnu-tools from:
36−#
37−# - GNU MCU Eclipse Windows Build Tools, which brings 'make', 'rm' etc.
38−# https://github.com/gnu-mcu-eclipse/windows-build-tools/releases
39−#
40−# - git for Windows, which brings 'find', 'grep' etc.
41−# https://git-scm.com/download/win
42−
43−
44−# normpath
45−#
46−# System-dependent normalization of the path name
47−#
48−# usage: $(call normpath,/path/to/file)
49−
50−normpath = $1
51−ifeq ($(OS),Windows_NT)
52− normpath = $(subst /,\,$1)
53−endif
54−
55−
56−# stolen from linux/Makefile
57−#
58−
5924ifeq ("$(origin V)", "command line")
60− KBUILD_VERBOSE = $(V)
25+ VERBOSE = $(V)
6126endif
62−ifndef KBUILD_VERBOSE
63− KBUILD_VERBOSE = 0
27+ifndef VERBOSE
28+ VERBOSE = 0
6429endif
6530
66−ifeq ($(KBUILD_VERBOSE),1)
31+export VERBOSE
32+
33+ifeq ($(VERBOSE),1)
6734 quiet =
6835 Q =
6936else
@@ -75,14 +42,8 @@ endif
7542#
7643
7744# Convenient variables
78−comma := ,
79−quote := "
80−#" this comment is only for emacs highlighting
8145squote := '
8246#' this comment is only for emacs highlighting
83−empty :=
84−space := $(empty) $(empty)
85−space_escape := _-_SPACE_-_
8647
8748# Find any prerequisites that is newer than target or that does not exist.
8849# PHONY targets skipped in both cases.
@@ -107,7 +68,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
10768# (5) No dir/.target.cmd file (used to store command line)
10869# (6) No dir/.target.cmd file and target not listed in $(targets)
10970# This is a good hint that there is a bug in the kbuild file
110−ifeq ($(KBUILD_VERBOSE),2)
71+ifeq ($(VERBOSE),2)
11172why = \
11273 $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
11374 $(if $(wildcard $@), \
utils/makefile.pythondeleted−269
@@ -1,269 +0,0 @@
1−# -*- coding: utf-8; mode: makefile-gmake -*-
2−
3−# list of python packages (folders) or modules (files) of this build
4−PYOBJECTS ?=
5−
6−SITE_PYTHON ?=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))site-python
7−export PYTHONPATH := $(SITE_PYTHON):$$PYTHONPATH
8−export PY_ENV PYDIST PYBUILD
9−
10−# folder where the python distribution takes place
11−PYDIST = ./$(LXC_ENV_FOLDER)dist
12−# folder where the python intermediate build files take place
13−PYBUILD = ./$(LXC_ENV_FOLDER)build
14−# python version to use
15−PY ?=3
16−# $(PYTHON) points to the python interpreter from the OS! The python from the
17−# OS is needed e.g. to create a virtualenv. For tasks inside the virtualenv the
18−# interpeter from '$(PY_ENV_BIN)/python' is used.
19−PYTHON ?= python$(PY)
20−PIP ?= pip$(PY)
21−PIP_INST ?= --user
22−
23−# https://www.python.org/dev/peps/pep-0508/#extras
24−#PY_SETUP_EXTRAS ?= \[develop,test\]
25−PY_SETUP_EXTRAS ?=
26−
27−PYDEBUG ?= --pdb
28−PYLINT_RC ?= .pylintrc
29−
30−TEST_FOLDER ?= ./tests
31−TEST ?= .
32−
33−PY_ENV = ./$(LXC_ENV_FOLDER)local/py$(PY)
34−PY_ENV_BIN = $(PY_ENV)/bin
35−PY_ENV_ACT = . $(PY_ENV_BIN)/activate
36−
37−ifeq ($(OS),Windows_NT)
38− PYTHON = python
39− PY_ENV_BIN = $(PY_ENV)/Scripts
40− PY_ENV_ACT = $(PY_ENV_BIN)/activate
41−endif
42−
43−VTENV_OPTS ?=
44−
45−python-help::
46− @echo 'makefile.python:'
47− @echo ' pyenv | pyenv[un]install'
48− @echo ' build $(PY_ENV) & [un]install python objects'
49− @echo ' targts using pyenv $(PY_ENV):'
50− @echo ' pylint - run pylint *linting*'
51− @echo ' pytest - run *tox* test on python objects'
52− @echo ' pydebug - run tests within a PDB debug session'
53− @echo ' pybuild - build python packages ($(PYDIST) $(PYBUILD))'
54− @echo ' pyclean - clean intermediate python objects'
55− @echo ' targets using system users environment:'
56− @echo ' py[un]install - [un]install python objects in editable mode'
57− @echo ' upload-pypi - upload $(PYDIST)/* files to PyPi'
58− @echo 'options:'
59− @echo ' make PY=3.7 [targets] => to eval targets with python 3.7 ($(PY))'
60− @echo ' make PIP_INST= => to set/unset pip install options ($(PIP_INST))'
61− @echo ' make TEST=. => choose test from $(TEST_FOLDER) (default "." runs all)'
62− @echo ' make DEBUG= => target "debug": do not invoke PDB on errors'
63− @echo ' make PY_SETUP_EXTRAS => also install extras_require from setup.py \[develop,test\]'
64− @echo ' when using target "pydebug", set breakpoints within py-source by adding::'
65− @echo ' DEBUG()'
66−
67−# ------------------------------------------------------------------------------
68−# OS requirements
69−# ------------------------------------------------------------------------------
70−
71−PHONY += msg-python-exe python-exe
72−msg-python-exe:
73− @echo "\n $(PYTHON) is required\n\n\
74− Make sure you have $(PYTHON) installed, grab it from\n\
75− https://www.python.org or install it from your package\n\
76− manager. On debian based OS these requirements are\n\
77− installed by::\n\n\
78− sudo -H add-apt-repository ppa:deadsnakes/ppa\n\
79− sudo -H apt update\n\
80− sudo -H apt-get install $(PYTHON) $(PYTHON)-venv\n"
81−
82−ifeq ($(shell which $(PYTHON) >/dev/null 2>&1; echo $$?), 1)
83−python-exe: msg-python-exe
84− $(error The '$(PYTHON)' command was not found)
85−else
86−python-exe:
87− @:
88−endif
89−
90−msg-pip-exe:
91− @echo "\n $(PIP) is required\n\n\
92− Make sure you have updated pip installed, grab it from\n\
93− https://pip.pypa.io or install it from your package\n\
94− manager. On debian based OS these requirements are\n\
95− installed by::\n\n\
96− sudo -H apt-get install python$(PY)-pip\n" | $(FMT)
97−
98−ifeq ($(shell which $(PIP) >/dev/null 2>&1; echo $$?), 1)
99−pip-exe: msg-pip-exe
100− $(error The '$(PIP)' command was not found)
101−else
102−pip-exe:
103− @:
104−endif
105−
106−# ------------------------------------------------------------------------------
107−# commands
108−# ------------------------------------------------------------------------------
109−
110−# $2 path to folder with setup.py, this uses pip from the OS
111−quiet_cmd_pyinstall = INSTALL $2
112− cmd_pyinstall = $(PIP) $(PIP_VERBOSE) install $(PIP_INST) -e $2$(PY_SETUP_EXTRAS)
113−
114−# $2 path to folder with setup.py, this uses pip from pyenv (not OS!)
115−quiet_cmd_pyenvinstall = PYENV install $2
116− cmd_pyenvinstall = \
117− if ! cat $(PY_ENV)/requirements.sha256 2>/dev/null | sha256sum --check --status 2>/dev/null; then \
118− rm -f $(PY_ENV)/requirements.sha256; \
119− $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS) &&\
120− sha256sum requirements*.txt > $(PY_ENV)/requirements.sha256 ;\
121− else \
122− echo "PYENV $2 already installed"; \
123− fi
124−
125−# Uninstall the package. Since pip does not uninstall the no longer needed
126−# depencies (something like autoremove) the depencies remain.
127−
128−# $2 package name to uninstall, this uses pip from the OS.
129−quiet_cmd_pyuninstall = UNINSTALL $2
130− cmd_pyuninstall = $(PIP) $(PIP_VERBOSE) uninstall --yes $2
131−
132−# $2 path to folder with setup.py, this uses pip from pyenv (not OS!)
133−quiet_cmd_pyenvuninstall = PYENV uninstall $2
134− cmd_pyenvuninstall = $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) uninstall --yes $2
135−
136−# $2 path to folder where virtualenv take place
137−quiet_cmd_virtualenv = PYENV usage: $ source ./$@/bin/activate
138− cmd_virtualenv = \
139− if [ -d "./$(PY_ENV)" -a -x "./$(PY_ENV_BIN)/python" ]; then \
140− echo "PYENV using virtualenv from $2"; \
141− else \
142− $(PYTHON) -m venv $(VTENV_OPTS) $2; \
143− $(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -U pip wheel setuptools; \
144− $(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -r requirements.txt; \
145− fi
146−
147−# $2 path to lint
148−quiet_cmd_pylint = LINT $@
149− cmd_pylint = $(PY_ENV_BIN)/python -m pylint -j 0 --rcfile $(PYLINT_RC) $2
150−
151−quiet_cmd_pytest = TEST $@
152− cmd_pytest = $(PY_ENV_BIN)/python -m tox -vv
153−
154−# setuptools, pip, easy_install its a mess full of cracks, a documentation hell
155−# and broken by design ... all sucks, I really, really hate all this ... aaargh!
156−#
157−# About python packaging see `Python Packaging Authority`_. Most of the names
158−# here are mapped to ``setup(<name1>=..., <name2>=...)`` arguments in
159−# ``setup.py``. See `Packaging and distributing projects`_ about ``setup(...)``
160−# arguments. If this is all new for you, start with `PyPI Quick and Dirty`_.
161−#
162−# Further read:
163−#
164−# - pythonwheels_
165−# - setuptools_
166−# - packaging_
167−# - sdist_
168−# - installing_
169−#
170−# .. _`Python Packaging Authority`: https://www.pypa.io
171−# .. _`Packaging and distributing projects`: https://packaging.python.org/guides/distributing-packages-using-setuptools/
172−# .. _`PyPI Quick and Dirty`: https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/
173−# .. _pythonwheels: https://pythonwheels.com/
174−# .. _setuptools: https://setuptools.readthedocs.io/en/latest/setuptools.html
175−# .. _packaging: https://packaging.python.org/guides/distributing-packages-using-setuptools/#packaging-and-distributing-projects
176−# .. _sdist: https://packaging.python.org/guides/distributing-packages-using-setuptools/#source-distributions
177−# .. _bdist_wheel: https://packaging.python.org/guides/distributing-packages-using-setuptools/#pure-python-wheels
178−# .. _installing: https://packaging.python.org/tutorials/installing-packages/
179−#
180−quiet_cmd_pybuild = BUILD $@
181− cmd_pybuild = $(PY_ENV_BIN)/python setup.py \
182− sdist -d $(PYDIST) \
183− bdist_wheel --bdist-dir $(PYBUILD) -d $(PYDIST)
184−
185−quiet_cmd_pyclean = CLEAN $@
186−# remove 'build' folder since bdist_wheel does not care the --bdist-dir
187− cmd_pyclean = \
188− rm -rf $(PYDIST) $(PYBUILD) $(PY_ENV) ./.tox *.egg-info ;\
189− find . -name '*.pyc' -exec rm -f {} + ;\
190− find . -name '*.pyo' -exec rm -f {} + ;\
191− find . -name __pycache__ -exec rm -rf {} +
192−
193−# ------------------------------------------------------------------------------
194−# targets
195−# ------------------------------------------------------------------------------
196−
197−# for installation use the pip from the OS!
198−PHONY += pyinstall
199−pyinstall: pip-exe
200− $(call cmd,pyinstall,.)
201−
202−PHONY += pyuninstall
203−pyuninstall: pip-exe
204− $(call cmd,pyuninstall,$(PYOBJECTS))
205−
206−# for installation use the pip from PY_ENV (not the OS)!
207−PHONY += pyenvinstall
208−pyenvinstall: $(PY_ENV)
209− $(call cmd,pyenvinstall,.)
210−
211−PHONY += pyenvuninstall
212−pyenvuninstall: $(PY_ENV)
213− $(call cmd,pyenvuninstall,$(PYOBJECTS))
214−
215−PHONY += pyclean
216−pyclean:
217− $(call cmd,pyclean)
218−
219−# to build *local* environment, python from the OS is needed!
220−pyenv: $(PY_ENV)
221−$(PY_ENV): python-exe
222− $(call cmd,virtualenv,$(PY_ENV))
223−
224−PHONY += pylint-exe
225−pylint-exe: $(PY_ENV)
226− @$(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install pylint
227−
228−PHONY += pylint
229−pylint: pylint-exe
230− $(call cmd,pylint,$(PYOBJECTS))
231−
232−PHONY += pybuild
233−pybuild: $(PY_ENV)
234− $(call cmd,pybuild)
235−
236−PHONY += pytest
237−pytest: $(PY_ENV)
238− $(call cmd,pytest)
239−
240−PHONY += pydebug
241−# set breakpoint with:
242−# DEBUG()
243−# e.g. to run tests in debug mode in emacs use:
244−# 'M-x pdb' ... 'make pydebug'
245−pydebug: $(PY_ENV)
246− DEBUG=$(DEBUG) $(PY_ENV_BIN)/pytest $(DEBUG) -v $(TEST_FOLDER)/$(TEST)
247−
248−# runs python interpreter from ./local/py<N>/bin/python
249−pyenv-python: pyenvinstall
250− $(PY_ENV_BIN)/python -i
251−
252−# With 'dependency_links=' setuptools supports dependencies on packages hosted
253−# on other reposetories then PyPi, see "Packages Not On PyPI" [1]. The big
254−# drawback is, due to security reasons (I don't know where the security gate on
255−# PyPi is), this feature is not supported by pip [2]. Thats why an upload to
256−# PyPi is required and since uploads via setuptools is not recommended, we have
257−# to imstall / use twine ... its really a mess.
258−#
259−# [1] https://python-packaging.readthedocs.io/en/latest/dependencies.html#packages-not-on-pypi
260−# [2] https://github.com/pypa/pip/pull/1519
261−
262−# https://github.com/pypa/twine
263−PHONY += upload-pypi upload-pypi-test
264−upload-pypi: pyclean pyenvinstall pybuild
265− @$(PY_ENV_BIN)/twine upload $(PYDIST)/*
266−
267−upload-pypi-test: pyclean pyenvinstall pybuild
268− @$(PY_ENV_BIN)/twine upload -r testpypi $(PYDIST)/*
269−.PHONY: $(PHONY)
utils/makefile.sphinxdeleted−199
@@ -1,199 +0,0 @@
1−# -*- coding: utf-8; mode: makefile-gmake -*-
2−
3−export DOCS_FOLDER DOCS_BUILD DOCS_DIST BOOKS_FOLDER BOOKS_DIST
4−
5−# You can set these variables from the command line.
6−SPHINXOPTS ?=
7−SPHINXBUILD ?= $(PY_ENV_BIN)/sphinx-build
8−SPHINX_CONF ?= conf.py
9−
10−DOCS_FOLDER = ./docs
11−DOCS_BUILD = ./$(LXC_ENV_FOLDER)build/docs
12−DOCS_DIST = ./$(LXC_ENV_FOLDER)dist/docs
13−GH_PAGES ?= build/gh-pages
14−
15−BOOKS_FOLDER = ./docs
16−BOOKS_DIST = ./$(LXC_ENV_FOLDER)dist/books
17−
18−ifeq ($(KBUILD_VERBOSE),1)
19− SPHINX_VERBOSE = "-v"
20−else
21− SPHINX_VERBOSE =
22−endif
23−
24−
25−docs-help:
26− @echo 'makefile.sphinx:'
27− @echo ' docs-clean - clean intermediate doc objects'
28− @echo ' $(GH_PAGES) - create & upload github pages'
29− @echo ' sphinx-pdf - run sphinx latex & pdf targets'
30− @echo ''
31− @echo ' books/{name}.html : build only the HTML of document {name}'
32− @echo ' valid values for books/{name}.html are:'
33− @echo ' $(BOOKS_HTML)' | $(FMT)
34− @echo ' books/{name}.pdf : build only the PDF of document {name}'
35− @echo ' valid values for books/{name}.pdf are:'
36− @echo ' $(BOOKS_PDF) ' | $(FMT)
37−
38−# ------------------------------------------------------------------------------
39−# requirements
40−# ------------------------------------------------------------------------------
41−
42−PHONY += msg-texlive texlive
43−
44−ifeq ($(shell which xelatex >/dev/null 2>&1; echo $$?), 1)
45−texlive: msg-TeXLive
46− $(error The 'xelatex' command was not found)
47−else
48−texlive:
49− @:
50−endif
51−
52−msg-texlive:
53− $(Q)echo "\n\
54−The TeX/PDF output and the *math* extension require TexLive and latexmk:\n\n\
55− Make sure you have a updated TeXLive with XeTeX engine installed, grab it\n\
56− it from https://www.tug.org/texlive or install it from your package manager.\n\n\
57− Install latexmk from your package manager or visit https://ctan.org/pkg/latexmk\n\n\
58− Sphinx-doc produce (Xe)LaTeX files which might use additional TeX-packages\n\
59− and fonts. To process these LaTeX files, a TexLive installation with the\n\
60− additional packages is required. On debian based OS these requirements\n\
61− are installed by::\n\n\
62− sudo -H apt-get install\n\
63− latexmk\n\
64− texlive-base texlive-xetex texlive-latex-recommended\n\
65− texlive-extra-utils dvipng ttf-dejavu\n"
66−
67−# ------------------------------------------------------------------------------
68−# commands
69−# ------------------------------------------------------------------------------
70−
71−# $2 sphinx builder e.g. "html"
72−# $3 path where configuration file (conf.py) is located
73−# $4 sourcedir
74−# $5 dest subfolder e.g. "man" for man pages at $(DOCS_DIST)/man
75−
76−quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(DOCS_DIST)/$5)
77− cmd_sphinx = SPHINX_CONF=$(abspath $4/$(SPHINX_CONF))\
78− $(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\
79− -b $2 -c $3 -d $(DOCS_BUILD)/.doctrees $4 $(DOCS_DIST)/$5
80−
81−quiet_cmd_sphinx_autobuild = SPHINX $@ --> file://$(abspath $(DOCS_DIST)/$5)
82− cmd_sphinx_autobuild = PATH="$(PY_ENV_BIN):$(PATH)" $(PY_ENV_BIN)/sphinx-autobuild $(SPHINX_VERBOSE) --open-browser --host 0.0.0.0 $(SPHINXOPTS)\
83− -b $2 -c $3 -d $(DOCS_BUILD)/.doctrees $4 $(DOCS_DIST)/$5
84−
85−quiet_cmd_sphinx_clean = CLEAN $@
86− cmd_sphinx_clean = rm -rf $(DOCS_BUILD) $(DOCS_DIST) $(GH_PAGES)/* $(GH_PAGES)/.buildinfo
87−
88−# ------------------------------------------------------------------------------
89−# targets
90−# ------------------------------------------------------------------------------
91−
92−# build PDF of whole documentation in: $(DOCS_DIST)/pdf
93−
94−PHONY += sphinx-pdf
95−sphinx-pdf: sphinx-latex
96− $(Q)cd $(DOCS_BUILD)/latex/; make all-pdf
97− $(Q)mkdir -p $(DOCS_DIST)/pdf
98− $(Q)cp $(DOCS_BUILD)/latex/*.pdf $(DOCS_DIST)/pdf
99− @echo "SPHINX *.pdf --> file://$(abspath $(DOCS_DIST)/pdf)"
100−
101−PHONY += sphinx-latex
102−sphinx-latex: pyenvinstall texlive
103− $(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\
104− -b latex \
105− -c $(DOCS_FOLDER) \
106− -d $(DOCS_BUILD)/.doctrees \
107− $(DOCS_FOLDER) \
108− $(DOCS_BUILD)/latex
109−
110−# Sphinx projects, we call them *books* (what is more common). Books are
111−# folders under $(BOOKS_FOLDER) containing a conf.py file. The HTML output goes
112−# to folder $(BOOKS_DIST)/<name> while PDF is placed (BOOKS_DIST)/<name>/pdf
113−
114−BOOKS=$(patsubst $(BOOKS_FOLDER)/%/conf.py,books/%,$(wildcard $(BOOKS_FOLDER)/*/conf.py))
115−
116−# fine grained targets
117−BOOKS_HTML = $(patsubst %,%.html,$(BOOKS))
118−BOOKS_CLEAN = $(patsubst %,%.clean,$(BOOKS))
119−BOOKS_LATEX = $(patsubst %,%.latex,$(BOOKS))
120−BOOKS_PDF = $(patsubst %,%.pdf,$(BOOKS))
121−BOOKS_LIVE = $(patsubst %,%.live,$(BOOKS))
122−
123−$(BOOKS_DIST):
124− mkdir -p $(BOOKS_DIST)
125−
126−PHONY += $(BOOKS_HTML)
127−$(BOOKS_HTML): pyenvinstall | $(BOOKS_DIST)
128− SPHINX_CONF=$(patsubst books/%.html,%,$@)/conf.py \
129− $(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\
130− -b html \
131− -c $(DOCS_FOLDER) \
132− -d $(DOCS_BUILD)/books/$(patsubst books/%.html,%,$@)/.doctrees \
133− $(BOOKS_FOLDER)/$(patsubst books/%.html,%,$@) \
134− $(BOOKS_DIST)/$(patsubst books/%.html,%,$@)
135− @echo "SPHINX $@ --> file://$(abspath $(BOOKS_DIST)/$(patsubst books/%.html,%,$@))"
136−
137−PHONY += $(BOOKS_HTML)
138−$(BOOKS_LIVE): pyenvinstall | $(BOOKS_DIST)
139− PATH="$(PY_ENV_BIN):$(PATH)" \
140− SPHINX_CONF=$(patsubst books/%.live,%,$@)/conf.py \
141− $(PY_ENV_BIN)/sphinx-autobuild --poll -B --host 0.0.0.0 --port 8080 $(SPHINX_VERBOSE) $(SPHINXOPTS)\
142− -b html \
143− -c $(DOCS_FOLDER) \
144− -d $(DOCS_BUILD)/books/$(patsubst books/%.live,%,$@)/.doctrees \
145− $(BOOKS_FOLDER)/$(patsubst books/%.live,%,$@) \
146− $(BOOKS_DIST)/$(patsubst books/%.live,%,$@)
147−
148−$(BOOKS_PDF): %.pdf : %.latex
149− $(Q)cd $(DOCS_BUILD)/latex/$(patsubst books/%.pdf,%,$@); make all-pdf
150− $(Q)mkdir -p $(BOOKS_DIST)/$(patsubst books/%.pdf,%,$@)/pdf
151− $(Q)cp -v $(DOCS_BUILD)/latex/$(patsubst books/%.pdf,%,$@)/*.pdf $(BOOKS_DIST)/$(patsubst books/%.pdf,%,$@)/pdf
152− @echo "SPHINX $@ --> file://$(abspath $(BOOKS_DIST)/$(patsubst books/%.pdf,%,$@))/pdf"
153−
154−PHONY += $(BOOKS_LATEX)
155−$(BOOKS_LATEX): pyenvinstall | $(BOOKS_DIST)
156− SPHINX_CONF=$(patsubst books/%.latex,%,$@)/conf.py \
157− $(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\
158− -b latex \
159− -c $(DOCS_FOLDER) \
160− -d $(DOCS_BUILD)/books/$(patsubst books/%.latex,%,$@)/.doctrees \
161− $(BOOKS_FOLDER)/$(patsubst books/%.latex,%,$@) \
162− $(DOCS_BUILD)/latex/$(patsubst books/%.latex,%,$@)
163− @echo "SPHINX $@ --> file://$(abspath $(DOCS_BUILD)/latex/$(patsubst books/%.latex,%,$@))"
164−
165−$(BOOKS_CLEAN):
166− $(Q)rm -rf $(BOOKS_DIST)/$(patsubst books/%.clean,%,$@) \
167− $(DOCS_BUILD)/books/$(patsubst books/%.clean,%,$@) \
168− $(DOCS_BUILD)/latex/$(patsubst books/%.clean,%,$@)
169−
170−# github pages
171−PHONY += prepare-gh-pages
172−prepare-gh-pages:
173− cp -r $(DOCS_DIST)/* $(GH_PAGES)/
174− touch $(GH_PAGES)/.nojekyll
175− echo "<html><head><META http-equiv='refresh' content='0;URL=index.html'></head></html>" > $(GH_PAGES)/404.html
176−
177−PHONY += gh-pages
178−gh-pages: docs-clean docs
179− - git worktree remove -f $(GH_PAGES) || exit 0
180− - git branch -D gh-pages || exit 0
181− git worktree add --no-checkout $(GH_PAGES) master
182− cd $(GH_PAGES); git checkout --orphan gh-pages && git rm -rfq .
183− $(MAKE) prepare-gh-pages
184− cd $(GH_PAGES);\
185− git add --all . ;\
186− git commit -q -m "make gh-pages: from $(shell git config --get remote.origin.url)@$(shell git rev-parse HEAD)" ;\
187− git push -f origin gh-pages
188−
189−PHONY += ci-gh-pages
190−ci-gh-pages: docs-clean docs
191− rm -Rf $(GH_PAGES)
192− mkdir -p $(GH_PAGES)
193− $(MAKE) prepare-gh-pages
194−
195−PHONY += docs-clean
196−docs-clean: $(BOOKS_CLEAN)
197− $(call cmd,sphinx_clean)
198−
199−.PHONY: $(PHONY)
utils/searx.sh+1−1
@@ -481,7 +481,7 @@ pyenv_is_available() {
481481create_pyenv() {
482482 rst_title "Create virtualenv (python)" section
483483 echo
484− if [[ ! -f "${SEARX_SRC}/manage.sh" ]]; then
484+ if [[ ! -f "${SEARX_SRC}/manage" ]]; then
485485 err_msg "to create pyenv for searx, searx has to be cloned first"
486486 return 42
487487 fi
utils/site-python/sphinx_build_tools.pydeleted−48
@@ -1,48 +0,0 @@
1−# -*- coding: utf-8; mode: python -*-
2−"""Implement some sphinx-build tools.
3−
4−"""
5−
6−import os
7−import sys
8−from sphinx.util.pycompat import execfile_
9−
10−# ------------------------------------------------------------------------------
11−def load_sphinx_config(namespace):
12−# ------------------------------------------------------------------------------
13−
14− u"""Load an additional configuration file into *namespace*.
15−
16− The name of the configuration file is taken from the environment
17− ``SPHINX_CONF``. The external configuration file extends (or overwrites) the
18− configuration values from the origin ``conf.py``. With this you are able to
19− maintain *build themes*. To your docs/conf.py add::
20−
21− from sphinx_build_tools import load_sphinx_config
22− ...
23−
24− # Since loadConfig overwrites settings from the global namespace, it has to be
25− # the last statement in the conf.py file
26−
27− load_sphinx_config(globals())
28−
29− """
30−
31− config_file = os.environ.get("SPHINX_CONF", None)
32− if (config_file is not None
33− and os.path.normpath(namespace["__file__"]) != os.path.normpath(config_file) ):
34− config_file = os.path.abspath(config_file)
35−
36− if os.path.isfile(config_file):
37− sys.stdout.write(
38− "load additional sphinx-config: %s\n"
39− % config_file)
40− config = namespace.copy()
41− config['__file__'] = config_file
42− execfile_(config_file, config)
43− del config['__file__']
44− namespace.update(config)
45− else:
46− sys.stderr.write(
47− "WARNING: additional sphinx-config not found: %s\n"
48− % config_file)