From 40843fe95ada52bc8791b4706392bda5afecf32e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 1 Mar 2020 07:56:46 +0100 Subject: searx/data/engines_languages.json: sort json file (no content change) To get meaningfull diffs, the json file has to be sorted. Before applying any further content patch, the json file needs a inital sort (without changing any content). Sorted by:: import sys, json with open('engines_languages.json') as f: j = json.load(f) with open('engines_languages.json', 'w') as f: json.dump(j, f, indent=2, sort_keys=True) Signed-off-by: Markus Heiser --- utils/fetch_languages.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'utils') diff --git a/utils/fetch_languages.py b/utils/fetch_languages.py index a6af07303..ddebb4111 100644 --- a/utils/fetch_languages.py +++ b/utils/fetch_languages.py @@ -5,7 +5,7 @@ # Output files (engines_languages.json and languages.py) # are written in current directory to avoid overwriting in case something goes wrong. -from json import dump +import json import io from sys import path from babel import Locale, UnknownLocaleError @@ -22,19 +22,22 @@ languages_file = 'languages.py' # Fetchs supported languages for each engine and writes json file with those. def fetch_supported_languages(): + engines_languages = {} - for engine_name in engines: + names = list(engines) + names.sort() + + for engine_name in names: + print("fetching languages of engine %s" % engine_name) + if hasattr(engines[engine_name], 'fetch_supported_languages'): - try: - engines_languages[engine_name] = engines[engine_name].fetch_supported_languages() - if type(engines_languages[engine_name]) == list: - engines_languages[engine_name] = sorted(engines_languages[engine_name]) - except Exception as e: - print(e) + engines_languages[engine_name] = engines[engine_name].fetch_supported_languages() + if type(engines_languages[engine_name]) == list: + engines_languages[engine_name] = sorted(engines_languages[engine_name]) # write json file - with io.open(engines_languages_file, "w", encoding="utf-8") as f: - dump(engines_languages, f, ensure_ascii=False, indent=4, separators=(',', ': ')) + with open(engines_languages_file, 'w', encoding='utf-8') as f: + json.dump(engines_languages, f, indent=2, sort_keys=True) return engines_languages -- cgit v1.2.3 From 442b27ac1b1f54669fbb9785d780327f62814431 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 29 Mar 2020 11:41:59 +0200 Subject: bash: use build environment from Makefile To Makefile target brand, add creation of bash environment in:: utils/brand.env In bash scripts (manage.sh) source env by:: . utils/brand.env manage.sh help: show GIT_URL and more environment Signed-off-by: Markus Heiser --- utils/brand.env | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 utils/brand.env (limited to 'utils') diff --git a/utils/brand.env b/utils/brand.env new file mode 100644 index 000000000..7fe1a3911 --- /dev/null +++ b/utils/brand.env @@ -0,0 +1,5 @@ +export GIT_URL='https://github.com/asciimoo/searx' +export ISSUE_URL='https://github.com/asciimoo/searx/issues' +export SEARX_URL='https://searx.me' +export DOCS_URL='https://asciimoo.github.io/searx' +export PUBLIC_INSTANCES='https://searx.space' -- cgit v1.2.3 From 9b48ae47ec837250a9a15e26f85ada33b7aa4f71 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 1 Apr 2020 14:16:49 +0200 Subject: makefile.python: hardening - drop virtualenv, drop build support py2 From py3.3 on a subset of virtualenv is built-in, so you can run '-m venv' ot of the box. - replace: $(PY_ENV_BIN)/pip --> $(PY_ENV_BIN)/python -m pip - remove obsolete virtualenv-exe target and adjust VTENV_OPTS - remove obsolete msg-pip-exe target - print list of py launchers available from $(PY_ENV_BIN) to the log - fix hard coded ./local Signed-off-by: Markus Heiser --- utils/makefile.python | 90 +++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 64 deletions(-) (limited to 'utils') diff --git a/utils/makefile.python b/utils/makefile.python index 4aa9d6b49..699bef5e1 100644 --- a/utils/makefile.python +++ b/utils/makefile.python @@ -5,6 +5,7 @@ PYOBJECTS ?= SITE_PYTHON ?=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))site-python export PYTHONPATH := $(SITE_PYTHON):$$PYTHONPATH +export PY_ENV PYDIST PYBUILD # folder where the python distribution takes place PYDIST ?= ./py_dist @@ -12,6 +13,9 @@ PYDIST ?= ./py_dist PYBUILD ?= ./py_build # python version to use PY ?=3 +# $(PYTHON) points to the python interpreter from the OS! The python from the +# OS is needed e.g. to create a virtualenv. For tasks inside the virtualenv the +# interpeter from '$(PY_ENV_BIN)/python' is used. PYTHON ?= python$(PY) PIP ?= pip$(PY) PIP_INST ?= --user @@ -26,7 +30,7 @@ PYLINT_RC ?= .pylintrc TEST_FOLDER ?= ./tests TEST ?= . -VTENV_OPTS = "--no-site-packages" +VTENV_OPTS ?= PY_ENV = ./local/py$(PY) PY_ENV_BIN = $(PY_ENV)/bin PY_ENV_ACT = . $(PY_ENV_BIN)/activate @@ -37,20 +41,6 @@ ifeq ($(OS),Windows_NT) PY_ENV_ACT = $(PY_ENV_BIN)/activate endif -ifeq ($(PYTHON),python) - VIRTUALENV = virtualenv -else - VIRTUALENV = virtualenv --python=$(PYTHON) -endif - -ifeq ($(KBUILD_VERBOSE),1) - PIP_VERBOSE = - VIRTUALENV_VERBOSE = -else - PIP_VERBOSE = "-q" - VIRTUALENV_VERBOSE = "-q" -endif - python-help:: @echo 'makefile.python:' @echo ' pyenv | pyenv[un]install' @@ -59,7 +49,7 @@ python-help:: @echo ' pylint - run pylint *linting*' @echo ' pytest - run *tox* test on python objects' @echo ' pydebug - run tests within a PDB debug session' - @echo ' pybuild - build python packages' + @echo ' pybuild - build python packages ($(PYDIST) $(PYBUILD))' @echo ' pyclean - clean intermediate python objects' @echo ' targets using system users environment:' @echo ' py[un]install - [un]install python objects in editable mode' @@ -94,38 +84,6 @@ python-exe: @: endif -msg-pip-exe: - @echo "\n $(PIP) is required\n\n\ - Make sure you have updated pip installed, grab it from\n\ - https://pip.pypa.io or install it from your package\n\ - manager. On debian based OS these requirements are\n\ - installed by::\n\n\ - sudo -H apt-get install python$(PY)-pip\n" | $(FMT) - -ifeq ($(shell which $(PIP) >/dev/null 2>&1; echo $$?), 1) -pip-exe: msg-pip-exe - $(error The '$(PIP)' command was not found) -else -pip-exe: - @: -endif - -PHONY += msg-virtualenv-exe virtualenv-exe -msg-virtualenv-exe: - @echo "\n virtualenv is required\n\n\ - Make sure you have an updated virtualenv installed, grab it from\n\ - https://virtualenv.pypa.io/en/stable/installation/ or install it\n\ - via pip by::\n\n\ - pip install --user https://github.com/pypa/virtualenv/tarball/master\n" | $(FMT) - -ifeq ($(shell which virtualenv >/dev/null 2>&1; echo $$?), 1) -virtualenv-exe: msg-virtualenv-exe - $(error The 'virtualenv' command was not found) -else -virtualenv-exe: - @: -endif - # ------------------------------------------------------------------------------ # commands # ------------------------------------------------------------------------------ @@ -136,9 +94,9 @@ quiet_cmd_pyinstall = INSTALL $2 # $2 path to folder with setup.py, this uses pip from pyenv (not OS!) quiet_cmd_pyenvinstall = PYENV install $2 - cmd_pyenvinstall = $(PY_ENV_BIN)/pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS) + cmd_pyenvinstall = $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS) -# Uninstall the package. Since pip does not uninstall the no longer needed +# Uninstall the package. Since pip does not uninstall the no longer needed # depencies (something like autoremove) the depencies remain. # $2 package name to uninstall, this uses pip from the OS. @@ -147,16 +105,19 @@ quiet_cmd_pyuninstall = UNINSTALL $2 # $2 path to folder with setup.py, this uses pip from pyenv (not OS!) quiet_cmd_pyenvuninstall = PYENV uninstall $2 - cmd_pyenvuninstall = $(PY_ENV_BIN)/pip $(PIP_VERBOSE) uninstall --yes $2 + cmd_pyenvuninstall = $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) uninstall --yes $2 # $2 path to folder where virtualenv take place +# creating a virtualenv uses $(PYTHON) from the OS! quiet_cmd_virtualenv = PYENV usage: $ source ./$@/bin/activate cmd_virtualenv = \ - if [ ! -d "./$(PY_ENV)" ];then \ - $(VIRTUALENV) $(VIRTUALENV_VERBOSE) $(VTENV_OPTS) $2; \ + if [ ! -d "$(PY_ENV)" ];then \ + echo "PYENV create virtualenv $2"; \ + $(PYTHON) -m venv $(VTENV_OPTS) $2; \ else \ echo "PYENV using virtualenv from $2"; \ - fi + fi; \ + echo "commands available at $(PY_ENV_BIN):"; ls $(PY_ENV_BIN) | $(FMT) ; # $2 path to lint quiet_cmd_pylint = LINT $@ @@ -192,14 +153,14 @@ quiet_cmd_pytest = TEST $@ # .. _installing: https://packaging.python.org/tutorials/installing-packages/ # quiet_cmd_pybuild = BUILD $@ - cmd_pybuild = $(PY_ENV_BIN)/$(PYTHON) setup.py \ + cmd_pybuild = $(PY_ENV_BIN)/python setup.py \ sdist -d $(PYDIST) \ bdist_wheel --bdist-dir $(PYBUILD) -d $(PYDIST) quiet_cmd_pyclean = CLEAN $@ # remove 'build' folder since bdist_wheel does not care the --bdist-dir cmd_pyclean = \ - rm -rf $(PYDIST) $(PYBUILD) ./local ./.tox *.egg-info ;\ + rm -rf $(PYDIST) $(PYBUILD) $(PY_ENV) ./.tox *.egg-info ;\ find . -name '*.pyc' -exec rm -f {} + ;\ find . -name '*.pyo' -exec rm -f {} + ;\ find . -name __pycache__ -exec rm -rf {} + @@ -230,15 +191,16 @@ PHONY += pyclean pyclean: $(call cmd,pyclean) -# to build *local* environment, python and virtualenv from the OS is needed! +# to build *local* environment, python from the OS is needed! pyenv: $(PY_ENV) -$(PY_ENV): virtualenv-exe python-exe +$(PY_ENV): python-exe $(call cmd,virtualenv,$(PY_ENV)) - @$(PY_ENV_BIN)/pip install $(PIP_VERBOSE) -r requirements.txt + $(Q)$(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -U pip wheel pip setuptools + $(Q)$(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -r requirements.txt PHONY += pylint-exe pylint-exe: $(PY_ENV) - @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) install pylint + @$(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install pylint PHONY += pylint pylint: pylint-exe @@ -262,15 +224,15 @@ pydebug: $(PY_ENV) # install / uninstall python objects into virtualenv (PYENV) pyenv-install: $(PY_ENV) - @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) install -e . + @$(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install -e . @echo "ACTIVATE $(call normpath,$(PY_ENV_ACT)) " pyenv-uninstall: $(PY_ENV) - @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) uninstall --yes . + @$(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) uninstall --yes . # runs python interpreter from ./local/py/bin/python pyenv-python: pyenv-install - cd ./local; ../$(PY_ENV_BIN)/python -i + $(PY_ENV_BIN)/python -i # With 'dependency_links=' setuptools supports dependencies on packages hosted # on other reposetories then PyPi, see "Packages Not On PyPI" [1]. The big @@ -284,7 +246,7 @@ pyenv-python: pyenv-install # https://github.com/pypa/twine PHONY += upload-pypi -upload-pypi: pyclean pybuild +upload-pypi: pyclean pyenvinstall pybuild @$(PY_ENV_BIN)/twine upload $(PYDIST)/* .PHONY: $(PHONY) -- cgit v1.2.3 From 31437d04e82ec9cde4209d881f6635ac39d92ac4 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 1 Apr 2020 16:07:59 +0200 Subject: makefile.python: hardening - start pylint by module - replace: $(PY_ENV_BIN)/pylint --> $(PY_ENV_BIN)/python -m pylint Signed-off-by: Markus Heiser --- utils/makefile.python | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/makefile.python b/utils/makefile.python index 699bef5e1..aaf21c115 100644 --- a/utils/makefile.python +++ b/utils/makefile.python @@ -121,10 +121,10 @@ quiet_cmd_virtualenv = PYENV usage: $ source ./$@/bin/activate # $2 path to lint quiet_cmd_pylint = LINT $@ - cmd_pylint = $(PY_ENV_BIN)/pylint --rcfile $(PYLINT_RC) $2 + cmd_pylint = $(PY_ENV_BIN)/python -m pylint --rcfile $(PYLINT_RC) $2 quiet_cmd_pytest = TEST $@ - cmd_pytest = $(PY_ENV_BIN)/tox -vv + cmd_pytest = $(PY_ENV_BIN)/python -m tox -vv # setuptools, pip, easy_install its a mess full of cracks, a documentation hell # and broken by design ... all sucks, I really, really hate all this ... aaargh! -- cgit v1.2.3 From 09a4062505a8d79451374139bab525457eeb28cd Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 1 Apr 2020 17:21:26 +0200 Subject: makefile.python: partial revert off 9b48ae47, adds py2 support back revert "makefile.python: ... drop build support py2" to get back Py2 support. TPy2 support need virtualenv installed by the OS. BTW: log environment and python version in travis's install phase Signed-off-by: Markus Heiser --- utils/makefile.python | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'utils') diff --git a/utils/makefile.python b/utils/makefile.python index aaf21c115..590bbdb46 100644 --- a/utils/makefile.python +++ b/utils/makefile.python @@ -30,7 +30,7 @@ PYLINT_RC ?= .pylintrc TEST_FOLDER ?= ./tests TEST ?= . -VTENV_OPTS ?= +VTENV_OPTS = "--no-site-packages" PY_ENV = ./local/py$(PY) PY_ENV_BIN = $(PY_ENV)/bin PY_ENV_ACT = . $(PY_ENV_BIN)/activate @@ -41,6 +41,20 @@ ifeq ($(OS),Windows_NT) PY_ENV_ACT = $(PY_ENV_BIN)/activate endif +ifeq ($(PYTHON),python) + VIRTUALENV = virtualenv +else + VIRTUALENV = virtualenv --python=$(PYTHON) +endif + +ifeq ($(KBUILD_VERBOSE),1) + PIP_VERBOSE = + VIRTUALENV_VERBOSE = +else + PIP_VERBOSE = "-q" + VIRTUALENV_VERBOSE = "-q" +endif + python-help:: @echo 'makefile.python:' @echo ' pyenv | pyenv[un]install' @@ -108,16 +122,13 @@ quiet_cmd_pyenvuninstall = PYENV uninstall $2 cmd_pyenvuninstall = $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) uninstall --yes $2 # $2 path to folder where virtualenv take place -# creating a virtualenv uses $(PYTHON) from the OS! quiet_cmd_virtualenv = PYENV usage: $ source ./$@/bin/activate cmd_virtualenv = \ - if [ ! -d "$(PY_ENV)" ];then \ - echo "PYENV create virtualenv $2"; \ - $(PYTHON) -m venv $(VTENV_OPTS) $2; \ + if [ ! -d "./$(PY_ENV)" ];then \ + $(VIRTUALENV) $(VIRTUALENV_VERBOSE) $(VTENV_OPTS) $2; \ else \ echo "PYENV using virtualenv from $2"; \ - fi; \ - echo "commands available at $(PY_ENV_BIN):"; ls $(PY_ENV_BIN) | $(FMT) ; + fi # $2 path to lint quiet_cmd_pylint = LINT $@ -- cgit v1.2.3 From 697dd6c6d3eec85e4703a38cd107800e5f3c8a13 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 22 Apr 2020 00:43:42 +0200 Subject: [fix] ffox useragent: use Windows NT 10.0 and not Windows NT 10 This is an addittion to PR #1934: The .0 change really counts on some engines like Bing which seems to allow Windows NT 10.0 but not Windows NT 10. Signed-off-by: Markus Heiser --- utils/fetch_firefox_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/fetch_firefox_version.py b/utils/fetch_firefox_version.py index ed179585b..722c48229 100755 --- a/utils/fetch_firefox_version.py +++ b/utils/fetch_firefox_version.py @@ -24,7 +24,7 @@ NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?$') # useragents = { "versions": (), - "os": ('Windows NT 10; WOW64', + "os": ('Windows NT 10.0; WOW64', 'X11; Linux x86_64'), "ua": "Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}" } -- cgit v1.2.3