Skip to content

Commit

Permalink
[fix] setup.py - packaging for 'answerers' to build a valid package
Browse files Browse the repository at this point in the history
Fix installing answerers when installing SearXNG through a wheel [1].  These
files have been missed in commit d72fa99.

Here is what have been tested:

    $ make clean py.build
    ...
    $ python -m venv test123
    $ . ./test123/bin/activate
    (test123) $ pip install dist/searxng-2024*-py3-none-any.whl
    (test123) $ SEARXNG_DEBUG=1 searxng-run

[1] searxng#3045 (comment)
  • Loading branch information
SuperSandro2000 authored and return42 committed Jun 17, 2024
1 parent f5eb56b commit 2e84dbe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions searx/answerers/random/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring
1 change: 1 addition & 0 deletions searx/answerers/random/answerer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring

import hashlib
import random
Expand Down
2 changes: 2 additions & 0 deletions searx/answerers/statistics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring
20 changes: 11 additions & 9 deletions searx/answerers/statistics/answerer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring

from functools import reduce
from operator import mul

Expand All @@ -18,27 +20,27 @@ def answer(query):

try:
args = list(map(float, parts[1:]))
except:
except: # pylint: disable=bare-except
return []

func = parts[0]
answer = None
_answer = None

if func == 'min':
answer = min(args)
_answer = min(args)
elif func == 'max':
answer = max(args)
_answer = max(args)
elif func == 'avg':
answer = sum(args) / len(args)
_answer = sum(args) / len(args)
elif func == 'sum':
answer = sum(args)
_answer = sum(args)
elif func == 'prod':
answer = reduce(mul, args, 1)
_answer = reduce(mul, args, 1)

if answer is None:
if _answer is None:
return []

return [{'answer': str(answer)}]
return [{'answer': str(_answer)}]


# required answerer function
Expand Down

0 comments on commit 2e84dbe

Please sign in to comment.