on master help sign in
Merge branch 'master' into tidy-oscar
commit7fbb15e05070de26c3b5b1958a2c2a42208bbe8b authorMarkus Heiser <markus.heiser@darmarIT.de> dateTue 10 Dec 2019, 15:41 (7 years ago) parentf34ac58f7a0510
7 files changed+1066−6
.dir-locals.el+133 .gitignore+3 .pylintrc+444 Makefile+62 setup.py+6−6 utils/makefile.include+128 utils/makefile.python+290
.dir-locals.elnew file+133
@@ -0,0 +1,133 @@
1+;;; .dir-locals.el
2+;;
3+;; If you get ``*** EPC Error ***`` (even after a jedi:install-server) in your
4+;; emacs session, mostly you have jedi-mode enabled but the python enviroment is
5+;; missed. The python environment has to be next to the
6+;; ``<repo>/.dir-locals.el`` in::
7+;;
8+;; ./local/py3
9+;;
10+;; In Emacs, some buffer locals are referencing the project environment:
11+;;
12+;; - prj-root --> <repo>/
13+;; - python-environment-directory --> <repo>/local
14+;; - python-environment-default-root-name --> py3
15+;; - python-shell-virtualenv-root --> <repo>/local/py3
16+;; When this variable is set with the path of the virtualenv to use,
17+;; `process-environment' and `exec-path' get proper values in order to run
18+;; shells inside the specified virtualenv, example::
19+;; (setq python-shell-virtualenv-root "/path/to/env/")
20+;;
21+;; To setup such an environment build target 'pyenv' or 'pyenvinstall'::
22+;;
23+;; $ make pyenvinstall
24+;;
25+;; Alternatively create the virtualenv, source it and install jedi + epc
26+;; (required by `emacs-jedi <https://tkf.github.io/emacs-jedi>`_)::
27+;;
28+;; $ virtualenv --python=python3 "--no-site-packages" ./local/py3
29+;; ...
30+;; $ source ./local/py3/bin/activate
31+;; (py3)$ # now install into the activated 'py3' environment ..
32+;; (py3)$ pip install jedi epc
33+;; ...
34+;;
35+;; Here is what also I found useful to add to my .emacs::
36+;;
37+;; (global-set-key [f6] 'flycheck-mode)
38+;; (add-hook 'python-mode-hook 'my:python-mode-hook)
39+;;
40+;; (defun my:python-mode-hook ()
41+;; (add-to-list 'company-backends 'company-jedi)
42+;; (require 'jedi-core)
43+;; (jedi:setup)
44+;; (define-key python-mode-map (kbd "C-c C-d") 'jedi:show-doc)
45+;; (define-key python-mode-map (kbd "M-.") 'jedi:goto-definition)
46+;; (define-key python-mode-map (kbd "M-,") 'jedi:goto-definition-pop-marker)
47+;; )
48+;;
49+
50+((nil
51+ . ((fill-column . 80)
52+ ))
53+ (python-mode
54+ . ((indent-tabs-mode . nil)
55+
56+ ;; project root folder is where the `.dir-locals.el' is located
57+ (eval . (setq-local
58+ prj-root (locate-dominating-file default-directory ".dir-locals.el")))
59+
60+ (eval . (setq-local
61+ python-environment-directory (expand-file-name "./local" prj-root)))
62+
63+ ;; use 'py3' enviroment as default
64+ (eval . (setq-local
65+ python-environment-default-root-name "py3"))
66+
67+ (eval . (setq-local
68+ python-shell-virtualenv-root
69+ (concat python-environment-directory
70+ "/"
71+ python-environment-default-root-name)))
72+
73+ ;; python-shell-virtualenv-path is obsolete, use python-shell-virtualenv-root!
74+ ;; (eval . (setq-local
75+ ;; python-shell-virtualenv-path python-shell-virtualenv-root))
76+
77+ (eval . (setq-local
78+ python-shell-interpreter
79+ (expand-file-name "bin/python" python-shell-virtualenv-root)))
80+
81+ (eval . (setq-local
82+ python-environment-virtualenv
83+ (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
84+ ;;"--system-site-packages"
85+ "--quiet")))
86+
87+ (eval . (setq-local
88+ pylint-command
89+ (expand-file-name "bin/pylint" python-shell-virtualenv-root)))
90+
91+ ;; pylint will find the '.pylintrc' file next to the CWD
92+ ;; https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
93+ (eval . (setq-local
94+ flycheck-pylintrc ".pylintrc"))
95+
96+ ;; flycheck & other python stuff should use the local py3 environment
97+ (eval . (setq-local
98+ flycheck-python-pylint-executable python-shell-interpreter))
99+
100+ ;; use 'M-x jedi:show-setup-info' and 'M-x epc:controller' to inspect jedi server
101+
102+ ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-root -- You
103+ ;; can specify a full path instead of a name (relative path). In that case,
104+ ;; python-environment-directory is ignored and Python virtual environment
105+ ;; is created at the specified path.
106+ (eval . (setq-local jedi:environment-root python-shell-virtualenv-root))
107+
108+ ;; https://tkf.github.io/emacs-jedi/latest/#jedi:server-command
109+ (eval .(setq-local
110+ jedi:server-command
111+ (list python-shell-interpreter
112+ jedi:server-script)
113+ ))
114+
115+ ;; jedi:environment-virtualenv --> see above 'python-environment-virtualenv'
116+ ;; is set buffer local! No need to setup jedi:environment-virtualenv:
117+ ;;
118+ ;; Virtualenv command to use. A list of string. If it is nil,
119+ ;; python-environment-virtualenv is used instead. You must set non-nil
120+ ;; value to jedi:environment-root in order to make this setting work.
121+ ;;
122+ ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-virtualenv
123+ ;;
124+ ;; (eval . (setq-local
125+ ;; jedi:environment-virtualenv
126+ ;; (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
127+ ;; ;;"--python"
128+ ;; ;;"/usr/bin/python3.4"
129+ ;; )))
130+
131+ ;; jedi:server-args
132+
133+ )))
.gitignore+3
@@ -18,3 +18,6 @@ setup.cfg
1818node_modules/
1919
2020.tx/
21+
22+local/
23+searx.egg-info/
.pylintrcnew file+444
@@ -0,0 +1,444 @@
1+# -*- coding: utf-8; mode: conf -*-
2+# lint Python modules using external checkers.
3+#
4+# This is the main checker controlling the other ones and the reports
5+# generation. It is itself both a raw checker and an astng checker in order
6+# to:
7+# * handle message activation / deactivation at the module level
8+# * handle some basic but necessary stats'data (number of classes, methods...)
9+#
10+[MASTER]
11+
12+# A comma-separated list of package or module names from where C extensions may
13+# be loaded. Extensions are loading into the active Python interpreter and may
14+# run arbitrary code
15+extension-pkg-whitelist=
16+
17+# Add files or directories to the blacklist. They should be base names, not
18+# paths.
19+ignore=CVS, .git, .svn
20+
21+# Add files or directories matching the regex patterns to the blacklist. The
22+# regex matches against base names, not paths.
23+ignore-patterns=
24+
25+# Python code to execute, usually for sys.path manipulation such as
26+# pygtk.require().
27+#init-hook=
28+
29+# Use multiple processes to speed up Pylint.
30+jobs=1
31+
32+# List of plugins (as comma separated values of python modules names) to load,
33+# usually to register additional checkers.
34+load-plugins=
35+
36+# Pickle collected data for later comparisons.
37+persistent=yes
38+
39+# Specify a configuration file.
40+#rcfile=
41+
42+# Allow loading of arbitrary C extensions. Extensions are imported into the
43+# active Python interpreter and may run arbitrary code.
44+unsafe-load-any-extension=no
45+
46+
47+[MESSAGES CONTROL]
48+
49+# Only show warnings with the listed confidence levels. Leave empty to show
50+# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
51+confidence=
52+
53+# Disable the message, report, category or checker with the given id(s). You
54+# can either give multiple identifiers separated by comma (,) or put this
55+# option multiple times (only on the command line, not in the configuration
56+# file where it should appear only once).You can also use "--disable=all" to
57+# disable everything first and then reenable specific checks. For example, if
58+# you want to run only the similarities checker, you can use "--disable=all
59+# --enable=similarities". If you want to run only the classes checker, but have
60+# no Warning level messages displayed, use"--disable=all --enable=classes
61+# --disable=W"
62+disable=bad-whitespace, duplicate-code
63+
64+# Enable the message, report, category or checker with the given id(s). You can
65+# either give multiple identifier separated by comma (,) or put this option
66+# multiple time (only on the command line, not in the configuration file where
67+# it should appear only once). See also the "--disable" option for examples.
68+enable=
69+
70+
71+[REPORTS]
72+
73+# Python expression which should return a note less than 10 (10 is the highest
74+# note). You have access to the variables errors warning, statement which
75+# respectively contain the number of errors / warnings messages and the total
76+# number of statements analyzed. This is used by the global evaluation report
77+# (RP0004).
78+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
79+
80+# Template used to display messages. This is a python new-style format string
81+# used to format the message information. See doc for all details
82+
83+# HINT: do not set this here, use argument --msg-template=...
84+#msg-template={path}:{line}: [{msg_id}({symbol}),{obj}] {msg}
85+
86+# Set the output format. Available formats are text, parseable, colorized, json
87+# and msvs (visual studio).You can also give a reporter class, eg
88+# mypackage.mymodule.MyReporterClass.
89+
90+# HINT: do not set this here, use argument --output-format=...
91+#output-format=text
92+
93+# Tells whether to display a full report or only the messages
94+reports=no
95+
96+# Activate the evaluation score.
97+score=yes
98+
99+
100+[REFACTORING]
101+
102+# Maximum number of nested blocks for function / method body
103+max-nested-blocks=5
104+
105+
106+[BASIC]
107+
108+# List of builtins function names that should not be used, separated by a comma
109+bad-functions=map,filter,apply,input
110+
111+# Naming hint for argument names
112+argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
113+
114+# Regular expression matching correct argument names
115+argument-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$
116+
117+# Naming hint for attribute names
118+attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
119+
120+# Regular expression matching correct attribute names
121+attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*)|([A-Z0-9_]*))$
122+
123+# Bad variable names which should always be refused, separated by a comma
124+bad-names=foo,bar,baz,toto,tutu,tata
125+
126+# Naming hint for class attribute names
127+class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
128+
129+# Regular expression matching correct class attribute names
130+class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
131+
132+# Naming hint for class names
133+class-name-hint=[A-Z_][a-zA-Z0-9]+$
134+
135+# Regular expression matching correct class names
136+class-rgx=[A-Z_][a-zA-Z0-9]+$
137+
138+# Naming hint for constant names
139+const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
140+
141+# Regular expression matching correct constant names
142+const-rgx=(([a-zA-Z_][a-zA-Z0-9_]*)|(__.*__))$
143+#const-rgx=[f]?[A-Z_][a-zA-Z0-9_]{2,30}$
144+
145+# Minimum line length for functions/classes that require docstrings, shorter
146+# ones are exempt.
147+docstring-min-length=-1
148+
149+# Naming hint for function names
150+function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
151+
152+# Regular expression matching correct function names
153+function-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$
154+
155+# Good variable names which should always be accepted, separated by a comma
156+good-names=i,j,k,ex,Run,_,log,cfg,id
157+
158+# Include a hint for the correct naming format with invalid-name
159+include-naming-hint=no
160+
161+# Naming hint for inline iteration names
162+inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
163+
164+# Regular expression matching correct inline iteration names
165+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
166+
167+# Naming hint for method names
168+method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
169+
170+# Regular expression matching correct method names
171+method-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$
172+
173+# Naming hint for module names
174+module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
175+
176+# Regular expression matching correct module names
177+#module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
178+module-rgx=([a-z_][a-z0-9_]*)$
179+
180+# Colon-delimited sets of names that determine each other's naming style when
181+# the name regexes allow several styles.
182+name-group=
183+
184+# Regular expression which should only match function or class names that do
185+# not require a docstring.
186+no-docstring-rgx=^_
187+
188+# List of decorators that produce properties, such as abc.abstractproperty. Add
189+# to this list to register other decorators that produce valid properties.
190+property-classes=abc.abstractproperty
191+
192+# Naming hint for variable names
193+variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
194+
195+# Regular expression matching correct variable names
196+variable-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*)|([a-z]))$
197+
198+
199+[FORMAT]
200+
201+# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
202+expected-line-ending-format=
203+
204+# Regexp for a line that is allowed to be longer than the limit.
205+ignore-long-lines=^\s*(# )?<?https?://\S+>?$
206+
207+# Number of spaces of indent required inside a hanging or continued line.
208+indent-after-paren=4
209+
210+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
211+# tab).
212+indent-string=' '
213+
214+# Maximum number of characters on a single line.
215+max-line-length=120
216+
217+# Maximum number of lines in a module
218+max-module-lines=2000
219+
220+# List of optional constructs for which whitespace checking is disabled. `dict-
221+# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
222+# `trailing-comma` allows a space between comma and closing bracket: (a, ).
223+# `empty-line` allows space-only lines.
224+no-space-check=trailing-comma,dict-separator
225+
226+# Allow the body of a class to be on the same line as the declaration if body
227+# contains single statement.No config file found, using default configuration
228+
229+single-line-class-stmt=no
230+
231+# Allow the body of an if to be on the same line as the test if there is no
232+# else.
233+single-line-if-stmt=no
234+
235+
236+[LOGGING]
237+
238+# Logging modules to check that the string format arguments are in logging
239+# function parameter format
240+logging-modules=logging
241+
242+
243+[MISCELLANEOUS]
244+
245+# List of note tags to take in consideration, separated by a comma.
246+notes=FIXME,XXX,TODO
247+
248+
249+[SIMILARITIES]
250+
251+# Ignore comments when computing similarities.
252+ignore-comments=yes
253+
254+# Ignore docstrings when computing similarities.
255+ignore-docstrings=yes
256+
257+# Ignore imports when computing similarities.
258+ignore-imports=no
259+
260+# Minimum lines number of a similarity.
261+min-similarity-lines=4
262+
263+
264+[SPELLING]
265+
266+# Spelling dictionary name. Available dictionaries: none. To make it working
267+# install python-enchant package.
268+spelling-dict=
269+
270+# List of comma separated words that should not be checked.
271+spelling-ignore-words=
272+
273+# A path to a file that contains private dictionary; one word per line.
274+spelling-private-dict-file=
275+
276+# Tells whether to store unknown words to indicated private dictionary in
277+# --spelling-private-dict-file option instead of raising a message.
278+spelling-store-unknown-words=no
279+
280+
281+[TYPECHECK]
282+
283+# List of decorators that produce context managers, such as
284+# contextlib.contextmanager. Add to this list to register other decorators that
285+# produce valid context managers.
286+contextmanager-decorators=contextlib.contextmanager
287+
288+# List of members which are set dynamically and missed by pylint inference
289+# system, and so shouldn't trigger E1101 when accessed. Python regular
290+# expressions are accepted.
291+generated-members=
292+
293+# Tells whether missing members accessed in mixin class should be ignored. A
294+# mixin class is detected if its name ends with "mixin" (case insensitive).
295+ignore-mixin-members=yes
296+
297+# This flag controls whether pylint should warn about no-member and similar
298+# checks whenever an opaque object is returned when inferring. The inference
299+# can return multiple potential results while evaluating a Python object, but
300+# some branches might not be evaluated, which results in partial inference. In
301+# that case, it might be useful to still emit no-member and other checks for
302+# the rest of the inferred objects.
303+ignore-on-opaque-inference=yes
304+
305+# List of class names for which member attributes should not be checked (useful
306+# for classes with dynamically set attributes). This supports the use of
307+# qualified names.
308+ignored-classes=optparse.Values,thread._local,_thread._local
309+
310+# List of module names for which member attributes should not be checked
311+# (useful for modules/projects where namespaces are manipulated during runtime
312+# and thus existing member attributes cannot be deduced by static analysis. It
313+# supports qualified module names, as well as Unix pattern matching.
314+ignored-modules=
315+
316+# Show a hint with possible names when a member name was not found. The aspect
317+# of finding the hint is based on edit distance.
318+missing-member-hint=yes
319+
320+# The minimum edit distance a name should have in order to be considered a
321+# similar match for a missing member name.
322+missing-member-hint-distance=1
323+
324+# The total number of similar names that should be taken in consideration when
325+# showing a hint for a missing member.
326+missing-member-max-choices=1
327+
328+
329+[VARIABLES]
330+
331+# List of additional names supposed to be defined in builtins. Remember that
332+# you should avoid to define new builtins when possible.
333+additional-builtins=
334+
335+# Tells whether unused global variables should be treated as a violation.
336+allow-global-unused-variables=yes
337+
338+# List of strings which can identify a callback function by name. A callback
339+# name must start or end with one of those strings.
340+callbacks=cb_,_cb
341+
342+# A regular expression matching the name of dummy variables (i.e. expectedly
343+# not used).
344+dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
345+
346+# Argument names that match this expression will be ignored. Default to name
347+# with leading underscore
348+ignored-argument-names=_.*|^ignored_|^unused_
349+
350+# Tells whether we should check for unused import in __init__ files.
351+init-import=no
352+
353+# List of qualified module names which can have objects that can redefine
354+# builtins.
355+redefining-builtins-modules=six.moves,future.builtins
356+
357+
358+[CLASSES]
359+
360+# List of method names used to declare (i.e. assign) instance attributes.
361+defining-attr-methods=__init__,__new__,setUp
362+
363+# List of member names, which should be excluded from the protected access
364+# warning.
365+exclude-protected=_asdict,_fields,_replace,_source,_make
366+
367+# List of valid names for the first argument in a class method.
368+valid-classmethod-first-arg=cls
369+
370+# List of valid names for the first argument in a metaclass class method.
371+valid-metaclass-classmethod-first-arg=mcs
372+
373+
374+[DESIGN]
375+
376+# Maximum number of arguments for function / method
377+max-args=8
378+
379+# Maximum number of attributes for a class (see R0902).
380+max-attributes=20
381+
382+# Maximum number of boolean expressions in a if statement
383+max-bool-expr=5
384+
385+# Maximum number of branch for function / method body
386+max-branches=12
387+
388+# Maximum number of locals for function / method body
389+max-locals=20
390+
391+# Maximum number of parents for a class (see R0901).
392+max-parents=7
393+
394+# Maximum number of public methods for a class (see R0904).
395+max-public-methods=20
396+
397+# Maximum number of return / yield for function / method body
398+max-returns=6
399+
400+# Maximum number of statements in function / method body
401+max-statements=50
402+
403+# Minimum number of public methods for a class (see R0903).
404+min-public-methods=2
405+
406+
407+[IMPORTS]
408+
409+# Allow wildcard imports from modules that define __all__.
410+allow-wildcard-with-all=no
411+
412+# Analyse import fallback blocks. This can be used to support both Python 2 and
413+# 3 compatible code, which means that the block might have code that exists
414+# only in one or another interpreter, leading to false positives when analysed.
415+analyse-fallback-blocks=no
416+
417+# Deprecated modules which should not be used, separated by a comma
418+deprecated-modules=optparse,tkinter.tix
419+
420+# Create a graph of external dependencies in the given file (report RP0402 must
421+# not be disabled)
422+ext-import-graph=
423+
424+# Create a graph of every (i.e. internal and external) dependencies in the
425+# given file (report RP0402 must not be disabled)
426+import-graph=
427+
428+# Create a graph of internal dependencies in the given file (report RP0402 must
429+# not be disabled)
430+int-import-graph=
431+
432+# Force import order to recognize a module as part of the standard
433+# compatibility libraries.
434+known-standard-library=
435+
436+# Force import order to recognize a module as part of a third party library.
437+known-third-party=enchant
438+
439+
440+[EXCEPTIONS]
441+
442+# Exceptions that will emit a warning when being caught. Defaults to
443+# "Exception"
444+overgeneral-exceptions=Exception
Makefilenew file+62
@@ -0,0 +1,62 @@
1+# -*- coding: utf-8; mode: makefile-gmake -*-
2+
3+PYOBJECTS = searx
4+PY_SETUP_EXTRAS ?= \[test\]
5+
6+include utils/makefile.include
7+include utils/makefile.python
8+
9+all: clean install
10+
11+PHONY += help
12+help:
13+ @echo ' test - run developer tests'
14+ @echo ' run - run developer instance'
15+ @echo ' install - developer install (./local)'
16+ @echo ' uninstall - uninstall (./local)'
17+ @echo ''
18+ @$(MAKE) -s -f utils/makefile.include make-help
19+ @echo ''
20+ @$(MAKE) -s -f utils/makefile.python python-help
21+
22+PHONY += install
23+install: pyenvinstall
24+
25+PHONY += uninstall
26+uninstall: pyenvuninstall
27+
28+PHONY += clean
29+clean: pyclean
30+ $(call cmd,common_clean)
31+
32+PHONY += run
33+run: pyenvinstall
34+ $(Q) ( \
35+ sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
36+ sleep 2 ; \
37+ xdg-open http://127.0.0.1:8888/ ; \
38+ sleep 3 ; \
39+ sed -i -e "s/debug : True/debug : False/g" ./searx/settings.yml ; \
40+ ) &
41+ $(PY_ENV)/bin/python ./searx/webapp.py
42+
43+# test
44+# ----
45+
46+PHONY += test test.pylint test.pep8 test.unit test.robot
47+
48+# TODO: balance linting with pylint
49+test: test.pep8 test.unit test.robot
50+ - make pylint
51+
52+test.pep8: pyenvinstall
53+ $(PY_ENV_ACT); ./manage.sh pep8_check
54+
55+test.unit: pyenvinstall
56+ $(PY_ENV_ACT); ./manage.sh unit_tests
57+
58+test.robot: pyenvinstall
59+ $(PY_ENV_ACT); ./manage.sh install_geckodriver
60+ $(PY_ENV_ACT); ./manage.sh robot_tests
61+
62+.PHONY: $(PHONY)
setup.py+6−6
@@ -11,14 +11,14 @@ import sys
1111sys.path.insert(0, './searx')
1212from version import VERSION_STRING
1313
14+with open('README.rst') as f:
15+ long_description = f.read()
1416
15−def read(*rnames):
16− return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
17+with open('requirements.txt') as f:
18+ requirements = [ l.strip() for l in f.readlines()]
1719
18−
19−long_description = read('README.rst')
20−requirements = map(str.strip, open('requirements.txt').readlines())
21−dev_requirements = map(str.strip, open('requirements-dev.txt').readlines())
20+with open('requirements-dev.txt') as f:
21+ dev_requirements = [ l.strip() for l in f.readlines()]
2222
2323setup(
2424 name='searx',
utils/makefile.includenew file+128
@@ -0,0 +1,128 @@
1+# -*- coding: utf-8; mode: makefile-gmake -*-
2+
3+make-help:
4+ @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
5+ @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
6+
7+quiet_cmd_common_clean = CLEAN $@
8+ cmd_common_clean = \
9+ rm -rf tests/build ;\
10+ find . -name '*.orig' -exec rm -f {} + ;\
11+ find . -name '*.rej' -exec rm -f {} + ;\
12+ find . -name '*~' -exec rm -f {} + ;\
13+ find . -name '*.bak' -exec rm -f {} + ;\
14+
15+FMT = cat
16+ifeq ($(shell which fmt >/dev/null 2>&1; echo $$?), 0)
17+FMT = fmt
18+endif
19+
20+# MS-Windows
21+#
22+# For a minimal *make-environment*, I'am using the gnu-tools from:
23+#
24+# - GNU MCU Eclipse Windows Build Tools, which brings 'make', 'rm' etc.
25+# https://github.com/gnu-mcu-eclipse/windows-build-tools/releases
26+#
27+# - git for Windows, which brings 'find', 'grep' etc.
28+# https://git-scm.com/download/win
29+
30+
31+# normpath
32+#
33+# System-dependent normalization of the path name
34+#
35+# usage: $(call normpath,/path/to/file)
36+
37+normpath = $1
38+ifeq ($(OS),Windows_NT)
39+ normpath = $(subst /,\,$1)
40+endif
41+
42+
43+# stolen from linux/Makefile
44+#
45+
46+ifeq ("$(origin V)", "command line")
47+ KBUILD_VERBOSE = $(V)
48+endif
49+ifndef KBUILD_VERBOSE
50+ KBUILD_VERBOSE = 0
51+endif
52+
53+ifeq ($(KBUILD_VERBOSE),1)
54+ quiet =
55+ Q =
56+else
57+ quiet=quiet_
58+ Q = @
59+endif
60+
61+# stolen from linux/scripts/Kbuild.include
62+#
63+
64+# Convenient variables
65+comma := ,
66+quote := "
67+#" this comment is only for emacs highlighting
68+squote := '
69+#' this comment is only for emacs highlighting
70+empty :=
71+space := $(empty) $(empty)
72+space_escape := _-_SPACE_-_
73+
74+# Find any prerequisites that is newer than target or that does not exist.
75+# PHONY targets skipped in both cases.
76+any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
77+#
78+###
79+# why - tell why a a target got build
80+# enabled by make V=2
81+# Output (listed in the order they are checked):
82+# (1) - due to target is PHONY
83+# (2) - due to target missing
84+# (3) - due to: file1.h file2.h
85+# (4) - due to command line change
86+# (5) - due to missing .cmd file
87+# (6) - due to target not in $(targets)
88+# (1) PHONY targets are always build
89+# (2) No target, so we better build it
90+# (3) Prerequisite is newer than target
91+# (4) The command line stored in the file named dir/.target.cmd
92+# differed from actual command line. This happens when compiler
93+# options changes
94+# (5) No dir/.target.cmd file (used to store command line)
95+# (6) No dir/.target.cmd file and target not listed in $(targets)
96+# This is a good hint that there is a bug in the kbuild file
97+ifeq ($(KBUILD_VERBOSE),2)
98+why = \
99+ $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
100+ $(if $(wildcard $@), \
101+ $(if $(strip $(any-prereq)),- due to: $(any-prereq), \
102+ $(if $(arg-check), \
103+ $(if $(cmd_$@),- due to command line change, \
104+ $(if $(filter $@, $(targets)), \
105+ - due to missing .cmd file, \
106+ - due to $(notdir $@) not in $$(targets) \
107+ ) \
108+ ) \
109+ ) \
110+ ), \
111+ - due to target missing \
112+ ) \
113+ )
114+
115+echo-why = $(call escsq, $(strip $(why)))
116+endif
117+#
118+###
119+# Escape single quote for use in echo statements
120+escsq = $(subst $(squote),'\$(squote)',$1)
121+#
122+# echo command.
123+# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
124+echo-cmd = $(if $($(quiet)cmd_$(1)),echo '$(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
125+#
126+# printing commands
127+cmd = @$(echo-cmd) $(cmd_$(1))
128+
utils/makefile.pythonnew file+290
@@ -0,0 +1,290 @@
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+
9+# folder where the python distribution takes place
10+PYDIST ?= ./py_dist
11+# folder where the python intermediate build files take place
12+PYBUILD ?= ./py_build
13+# python version to use
14+PY ?=3
15+PYTHON ?= python$(PY)
16+PIP ?= pip$(PY)
17+PIP_INST ?= --user
18+
19+# https://www.python.org/dev/peps/pep-0508/#extras
20+#PY_SETUP_EXTRAS ?= \[develop,test\]
21+PY_SETUP_EXTRAS ?=
22+
23+PYDEBUG ?= --pdb
24+PYLINT_RC ?= .pylintrc
25+
26+TEST_FOLDER ?= ./tests
27+TEST ?= .
28+
29+VTENV_OPTS = "--no-site-packages"
30+PY_ENV = ./local/py$(PY)
31+PY_ENV_BIN = $(PY_ENV)/bin
32+PY_ENV_ACT = . $(PY_ENV_BIN)/activate
33+
34+ifeq ($(OS),Windows_NT)
35+ PYTHON = python
36+ PY_ENV_BIN = $(PY_ENV)/Scripts
37+ PY_ENV_ACT = $(PY_ENV_BIN)/activate
38+endif
39+
40+ifeq ($(PYTHON),python)
41+ VIRTUALENV = virtualenv
42+else
43+ VIRTUALENV = virtualenv --python=$(PYTHON)
44+endif
45+
46+ifeq ($(KBUILD_VERBOSE),1)
47+ PIP_VERBOSE =
48+ VIRTUALENV_VERBOSE =
49+else
50+ PIP_VERBOSE = "-q"
51+ VIRTUALENV_VERBOSE = "-q"
52+endif
53+
54+python-help::
55+ @echo 'makefile.python:'
56+ @echo ' pyenv | pyenv[un]install'
57+ @echo ' build $(PY_ENV) & [un]install python objects'
58+ @echo ' targts using pyenv $(PY_ENV):'
59+ @echo ' pylint - run pylint *linting*'
60+ @echo ' pytest - run *tox* test on python objects'
61+ @echo ' pydebug - run tests within a PDB debug session'
62+ @echo ' pybuild - build python packages'
63+ @echo ' pyclean - clean intermediate python objects'
64+ @echo ' targets using system users environment:'
65+ @echo ' py[un]install - [un]install python objects in editable mode'
66+ @echo ' upload-pypi - upload $(PYDIST)/* files to PyPi'
67+ @echo 'options:'
68+ @echo ' make PY=2 [targets] => to eval targets with python 2 ($(PY))'
69+ @echo ' make PIP_INST= => to set/unset pip install options ($(PIP_INST))'
70+ @echo ' make TEST=. => choose test from $(TEST_FOLDER) (default "." runs all)'
71+ @echo ' make DEBUG= => target "debug": do not invoke PDB on errors'
72+ @echo ' make PY_SETUP_EXTRAS => also install extras_require from setup.py \[develop,test\]'
73+ @echo ' when using target "pydebug", set breakpoints within py-source by adding::'
74+ @echo ' DEBUG()'
75+
76+# ------------------------------------------------------------------------------
77+# OS requirements
78+# ------------------------------------------------------------------------------
79+
80+PHONY += msg-python-exe python-exe
81+msg-python-exe:
82+ @echo "\n $(PYTHON) is required\n\n\
83+ Make sure you have $(PYTHON) installed, grab it from\n\
84+ https://www.python.org or install it from your package\n\
85+ manager. On debian based OS these requirements are\n\
86+ installed by::\n\n\
87+ sudo -H apt-get install $(PYTHON)\n" | $(FMT)
88+
89+ifeq ($(shell which $(PYTHON) >/dev/null 2>&1; echo $$?), 1)
90+python-exe: msg-python-exe
91+ $(error The '$(PYTHON)' command was not found)
92+else
93+python-exe:
94+ @:
95+endif
96+
97+msg-pip-exe:
98+ @echo "\n $(PIP) is required\n\n\
99+ Make sure you have updated pip installed, grab it from\n\
100+ https://pip.pypa.io or install it from your package\n\
101+ manager. On debian based OS these requirements are\n\
102+ installed by::\n\n\
103+ sudo -H apt-get install python$(PY)-pip\n" | $(FMT)
104+
105+ifeq ($(shell which $(PIP) >/dev/null 2>&1; echo $$?), 1)
106+pip-exe: msg-pip-exe
107+ $(error The '$(PIP)' command was not found)
108+else
109+pip-exe:
110+ @:
111+endif
112+
113+PHONY += msg-virtualenv-exe virtualenv-exe
114+msg-virtualenv-exe:
115+ @echo "\n virtualenv is required\n\n\
116+ Make sure you have an updated virtualenv installed, grab it from\n\
117+ https://virtualenv.pypa.io/en/stable/installation/ or install it\n\
118+ via pip by::\n\n\
119+ pip install --user https://github.com/pypa/virtualenv/tarball/master\n" | $(FMT)
120+
121+ifeq ($(shell which virtualenv >/dev/null 2>&1; echo $$?), 1)
122+virtualenv-exe: msg-virtualenv-exe
123+ $(error The 'virtualenv' command was not found)
124+else
125+virtualenv-exe:
126+ @:
127+endif
128+
129+# ------------------------------------------------------------------------------
130+# commands
131+# ------------------------------------------------------------------------------
132+
133+# $2 path to folder with setup.py, this uses pip from the OS
134+quiet_cmd_pyinstall = INSTALL $2
135+ cmd_pyinstall = $(PIP) $(PIP_VERBOSE) install $(PIP_INST) -e $2$(PY_SETUP_EXTRAS)
136+
137+# $2 path to folder with setup.py, this uses pip from pyenv (not OS!)
138+quiet_cmd_pyenvinstall = PYENV install $2
139+ cmd_pyenvinstall = $(PY_ENV_BIN)/pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS)
140+
141+# Uninstall the package. Since pip does not uninstall the no longer needed
142+# depencies (something like autoremove) the depencies remain.
143+
144+# $2 package name to uninstall, this uses pip from the OS.
145+quiet_cmd_pyuninstall = UNINSTALL $2
146+ cmd_pyuninstall = $(PIP) $(PIP_VERBOSE) uninstall --yes $2
147+
148+# $2 path to folder with setup.py, this uses pip from pyenv (not OS!)
149+quiet_cmd_pyenvuninstall = PYENV uninstall $2
150+ cmd_pyenvuninstall = $(PY_ENV_BIN)/pip $(PIP_VERBOSE) uninstall --yes $2
151+
152+# $2 path to folder where virtualenv take place
153+quiet_cmd_virtualenv = PYENV usage: $ source ./$@/bin/activate
154+ cmd_virtualenv = \
155+ if [ ! -d "./$(PY_ENV)" ];then \
156+ $(VIRTUALENV) $(VIRTUALENV_VERBOSE) $(VTENV_OPTS) $2; \
157+ else \
158+ echo " PYENV using virtualenv from $2"; \
159+ fi
160+
161+# $2 path to lint
162+quiet_cmd_pylint = LINT $@
163+ cmd_pylint = $(PY_ENV_BIN)/pylint --rcfile $(PYLINT_RC) $2
164+
165+quiet_cmd_pytest = TEST $@
166+ cmd_pytest = $(PY_ENV_BIN)/tox -vv
167+
168+# setuptools, pip, easy_install its a mess full of cracks, a documentation hell
169+# and broken by design ... all sucks, I really, really hate all this ... aaargh!
170+#
171+# About python packaging see `Python Packaging Authority`_. Most of the names
172+# here are mapped to ``setup(<name1>=..., <name2>=...)`` arguments in
173+# ``setup.py``. See `Packaging and distributing projects`_ about ``setup(...)``
174+# arguments. If this is all new for you, start with `PyPI Quick and Dirty`_.
175+#
176+# Further read:
177+#
178+# - pythonwheels_
179+# - setuptools_
180+# - packaging_
181+# - sdist_
182+# - installing_
183+#
184+# .. _`Python Packaging Authority`: https://www.pypa.io
185+# .. _`Packaging and distributing projects`: https://packaging.python.org/guides/distributing-packages-using-setuptools/
186+# .. _`PyPI Quick and Dirty`: https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/
187+# .. _pythonwheels: https://pythonwheels.com/
188+# .. _setuptools: https://setuptools.readthedocs.io/en/latest/setuptools.html
189+# .. _packaging: https://packaging.python.org/guides/distributing-packages-using-setuptools/#packaging-and-distributing-projects
190+# .. _sdist: https://packaging.python.org/guides/distributing-packages-using-setuptools/#source-distributions
191+# .. _bdist_wheel: https://packaging.python.org/guides/distributing-packages-using-setuptools/#pure-python-wheels
192+# .. _installing: https://packaging.python.org/tutorials/installing-packages/
193+#
194+quiet_cmd_pybuild = BUILD $@
195+ cmd_pybuild = $(PY_ENV_BIN)/$(PYTHON) setup.py \
196+ sdist -d $(PYDIST) \
197+ bdist_wheel --bdist-dir $(PYBUILD) -d $(PYDIST)
198+
199+quiet_cmd_pyclean = CLEAN $@
200+# remove 'build' folder since bdist_wheel does not care the --bdist-dir
201+ cmd_pyclean = \
202+ rm -rf $(PYDIST) $(PYBUILD) ./local ./.tox *.egg-info ;\
203+ find . -name '*.pyc' -exec rm -f {} + ;\
204+ find . -name '*.pyo' -exec rm -f {} + ;\
205+ find . -name __pycache__ -exec rm -rf {} +
206+
207+# ------------------------------------------------------------------------------
208+# targets
209+# ------------------------------------------------------------------------------
210+
211+# for installation use the pip from the OS!
212+PHONY += pyinstall
213+pyinstall: pip-exe
214+ $(call cmd,pyinstall,.)
215+
216+PHONY += pyuninstall
217+pyuninstall: pip-exe
218+ $(call cmd,pyuninstall,$(PYOBJECTS))
219+
220+# for installation use the pip from PY_ENV (not the OS)!
221+PHONY += pyenvinstall
222+pyenvinstall: $(PY_ENV)
223+ $(call cmd,pyenvinstall,.)
224+
225+PHONY += pyenvuninstall
226+pyenvuninstall: $(PY_ENV)
227+ $(call cmd,pyenvuninstall,$(PYOBJECTS))
228+
229+PHONY += pyclean
230+pyclean:
231+ $(call cmd,pyclean)
232+
233+# to build *local* environment, python and virtualenv from the OS is needed!
234+pyenv: $(PY_ENV)
235+$(PY_ENV): virtualenv-exe python-exe
236+ $(call cmd,virtualenv,$(PY_ENV))
237+ @$(PY_ENV_BIN)/pip install $(PIP_VERBOSE) -r requirements.txt
238+
239+PHONY += pylint-exe
240+pylint-exe: $(PY_ENV)
241+ @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) install pylint
242+
243+PHONY += pylint
244+pylint: pylint-exe
245+ $(call cmd,pylint,$(PYOBJECTS))
246+
247+PHONY += pybuild
248+pybuild: $(PY_ENV)
249+ $(call cmd,pybuild)
250+
251+PHONY += pytest
252+pytest: $(PY_ENV)
253+ $(call cmd,pytest)
254+
255+PHONY += pydebug
256+# set breakpoint with:
257+# DEBUG()
258+# e.g. to run tests in debug mode in emacs use:
259+# 'M-x pdb' ... 'make pydebug'
260+pydebug: $(PY_ENV)
261+ DEBUG=$(DEBUG) $(PY_ENV_BIN)/pytest $(DEBUG) -v $(TEST_FOLDER)/$(TEST)
262+
263+# install / uninstall python objects into virtualenv (PYENV)
264+pyenv-install: $(PY_ENV)
265+ @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) install -e .
266+ @echo " ACTIVATE $(call normpath,$(PY_ENV_ACT)) "
267+
268+pyenv-uninstall: $(PY_ENV)
269+ @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) uninstall --yes .
270+
271+# runs python interpreter from ./local/py<N>/bin/python
272+pyenv-python: pyenv-install
273+ cd ./local; ../$(PY_ENV_BIN)/python -i
274+
275+# With 'dependency_links=' setuptools supports dependencies on packages hosted
276+# on other reposetories then PyPi, see "Packages Not On PyPI" [1]. The big
277+# drawback is, due to security reasons (I don't know where the security gate on
278+# PyPi is), this feature is not supported by pip [2]. Thats why an upload to
279+# PyPi is required and since uploads via setuptools is not recommended, we have
280+# to imstall / use twine ... its really a mess.
281+#
282+# [1] http://python-packaging.readthedocs.io/en/latest/dependencies.html#packages-not-on-pypi
283+# [2] https://github.com/pypa/pip/pull/1519
284+
285+# https://github.com/pypa/twine
286+PHONY += upload-pypi
287+upload-pypi: pyclean pybuild
288+ @$(PY_ENV_BIN)/twine upload $(PYDIST)/*
289+
290+.PHONY: $(PHONY)