This commit is contained in:
Alexandre Flament 2023-02-13 11:26:58 +01:00 committed by GitHub
commit eaad7ceb2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 86 deletions

8
pyproject.toml Normal file
View file

@ -0,0 +1,8 @@
[build-system]
requires = [
"setuptools>=45",
"setuptools_scm[toml]>=6.2",
"wheel",
"pyaml"
]
build-backend = "setuptools.build_meta"

View file

@ -1,22 +0,0 @@
mock==5.0.1
nose2[coverage_plugin]==0.12.0
cov-core==1.15.0
black==22.12.0
pylint==2.16.1
splinter==0.19.0
selenium==4.8.0
twine==4.0.2
Pallets-Sphinx-Themes==2.0.3
Sphinx==5.3.0
sphinx-issues==3.0.1
sphinx-jinja==2.0.2
sphinx-tabs==3.4.1
sphinxcontrib-programoutput==0.17
sphinx-autobuild==2021.3.14
sphinx-notfound-page==0.8.3
myst-parser==0.18.1
linuxdoc==20221127
aiounittest==1.4.2
yamllint==1.29.0
wlc==1.13
coloredlogs==15.0.1

View file

@ -1,18 +1,23 @@
certifi==2022.12.7 -e .
babel==2.11.0 mock==5.0.1
flask-babel==3.0.1 nose2[coverage_plugin]==0.12.0
flask==2.2.2 cov-core==1.15.0
jinja2==3.1.2 black==22.12.0
lxml==4.9.2 pylint==2.16.1
pygments==2.14.0 splinter==0.19.0
python-dateutil==2.8.2 selenium==4.8.0
pyyaml==6.0 twine==4.0.2
httpx[http2]==0.21.2 Pallets-Sphinx-Themes==2.0.3
Brotli==1.0.9 Sphinx==5.3.0
uvloop==0.17.0 sphinx-issues==3.0.1
httpx-socks[asyncio]==0.7.2 sphinx-jinja==2.0.2
setproctitle==1.3.2 sphinx-tabs==3.4.1
redis==4.5.1 sphinxcontrib-programoutput==0.17
markdown-it-py==2.1.0 sphinx-autobuild==2021.3.14
typing_extensions==4.4.0 sphinx-notfound-page==0.8.3
fasttext-predict==0.9.2.1 myst-parser==0.18.1
linuxdoc==20221127
aiounittest==1.4.2
yamllint==1.29.0
wlc==1.13
coloredlogs==15.0.1

View file

@ -11,9 +11,26 @@ import os
import logging import logging
from base64 import b64decode from base64 import b64decode
from os.path import dirname, abspath from os.path import dirname, abspath
from importlib import metadata
from searx.languages import language_codes as languages from searx.languages import language_codes as languages
try:
metadata = metadata.metadata('searxng')
project_urls = {}
for k, v in metadata.items():
if k == 'Project-URL':
url_type, url = v.split(',')
project_urls[url_type.strip()] = url.strip()
except metadata.PackageNotFoundError:
project_urls = {
"Code": "https://github.com/searxng/searxng",
"Documentation": 'https://docs.searxng.org/',
"Issue tracker": 'https://github.com/searxng/searxng/issues',
"New issue": 'https://github.com/searxng/searxng/issues/new',
'Public instances': 'https//searx.space',
}
searx_dir = abspath(dirname(__file__)) searx_dir = abspath(dirname(__file__))
logger = logging.getLogger('searx') logger = logging.getLogger('searx')
@ -146,11 +163,10 @@ SCHEMA = {
'enable_metrics': SettingsValue(bool, True), 'enable_metrics': SettingsValue(bool, True),
}, },
'brand': { 'brand': {
'issue_url': SettingsValue(str, 'https://github.com/searxng/searxng/issues'), 'issue_url': SettingsValue(str, project_urls['Issue tracker']),
'new_issue_url': SettingsValue(str, 'https://github.com/searxng/searxng/issues/new'), 'new_issue_url': SettingsValue(str, project_urls['New issue']),
'docs_url': SettingsValue(str, 'https://docs.searxng.org'), 'docs_url': SettingsValue(str, project_urls['Documentation']),
'public_instances': SettingsValue((False, str), 'https://searx.space'), 'public_instances': SettingsValue((False, str), project_urls['Public instances']),
'wiki_url': SettingsValue(str, 'https://github.com/searxng/searxng/wiki'),
}, },
'search': { 'search': {
'safe_search': SettingsValue((0, 1, 2), 0), 'safe_search': SettingsValue((0, 1, 2), 0),

View file

@ -10,8 +10,8 @@ import importlib
# fallback values # fallback values
# if there is searx.version_frozen module, and it is not possible to get the git tag # if there is searx.version_frozen module, and it is not possible to get the git tag
VERSION_STRING = "1.0.0" VERSION_STRING = "2.0.0"
VERSION_TAG = "1.0.0" VERSION_TAG = "2.0.0"
GIT_URL = "unknow" GIT_URL = "unknow"
GIT_BRANCH = "unknow" GIT_BRANCH = "unknow"
@ -67,7 +67,7 @@ def get_git_version():
subprocess_run("git diff --quiet -- . ':!searx/settings.yml' ':!utils/brand.env'") subprocess_run("git diff --quiet -- . ':!searx/settings.yml' ':!utils/brand.env'")
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
if e.returncode == 1: if e.returncode == 1:
git_version += "+dirty" git_version += ".dirty"
else: else:
logger.warning('"%s" returns an unexpected return code %i', e.returncode, e.cmd) logger.warning('"%s" returns an unexpected return code %i', e.returncode, e.cmd)
docker_tag = git_version.replace("+", "-") docker_tag = git_version.replace("+", "-")
@ -76,13 +76,12 @@ def get_git_version():
try: try:
vf = importlib.import_module('searx.version_frozen') vf = importlib.import_module('searx.version_frozen')
VERSION_STRING, VERSION_TAG, DOCKER_TAG, GIT_URL, GIT_BRANCH = ( vt = vf.version_tuple
vf.VERSION_STRING, VERSION_STRING = vf.version
vf.VERSION_TAG, VERSION_TAG = f"{vt[0]}.{vt[1]}.{vt[2]}-{vt[3].split('.')[0]}"
vf.DOCKER_TAG, DOCKER_TAG = f"{vt[0]}.{vt[1]}.{vt[2]}-{vt[3]}"
vf.GIT_URL, GIR_URL = ""
vf.GIT_BRANCH, GIT_BRANCH = ""
)
except ImportError: except ImportError:
try: try:
try: try:

View file

@ -1,31 +1,42 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Installer for SearXNG package.""" """Installer for SearXNG package."""
from setuptools import setup from setuptools import setup, find_packages
from setuptools import find_packages
from searx.version import VERSION_TAG, GIT_URL
from searx import get_setting
with open('README.rst', encoding='utf-8') as f: with open('README.rst', encoding='utf-8') as f:
long_description = f.read() long_description = f.read()
with open('requirements.txt') as f:
requirements = [ l.strip() for l in f.readlines()]
with open('requirements-dev.txt') as f: def version_yyyymmdd_tag():
dev_requirements = [ l.strip() for l in f.readlines()] from setuptools_scm.version import ScmVersion
def custom_version_scheme(version: ScmVersion):
return f"{version.node_date.year}.{version.node_date.month}.{version.node_date.day}+{version.node}"
def custom_local_scheme(version: ScmVersion):
return '.dirty' if version.dirty else ''
# FIXME : GIT_URL and GIT_BRANCH are missing from searx/version_frozen.py
return {
'write_to': 'searx/version_frozen.py',
'version_scheme': custom_version_scheme,
'local_scheme': custom_local_scheme
}
setup( setup(
name='searxng', name='searxng',
python_requires=">=3.7", python_requires=">=3.7",
version=VERSION_TAG,
description="A privacy-respecting, hackable metasearch engine", description="A privacy-respecting, hackable metasearch engine",
long_description=long_description, long_description=long_description,
url=get_setting('brand.docs_url'), use_scm_version=version_yyyymmdd_tag,
url='https://docs.searxng.org/',
project_urls={ project_urls={
"Code": GIT_URL, "Code": 'https://github.com/searxng/searxng',
"Issue tracker": get_setting('brand.issue_url') "Documentation": 'https://docs.searxng.org/',
"Issue tracker": 'https://github.com/searxng/searxng/issues',
"New issue": 'https://github.com/searxng/searxng/issues/new',
'Public instances': 'https//searx.space',
}, },
classifiers=[ classifiers=[
"Development Status :: 4 - Beta", "Development Status :: 4 - Beta",
@ -39,24 +50,38 @@ setup(
author='SearXNG dev team', author='SearXNG dev team',
author_email='contact@searxng.org', author_email='contact@searxng.org',
license='GNU Affero General Public License', license='GNU Affero General Public License',
packages=find_packages(exclude=["tests*", "searxng_extra"]), packages=find_packages(exclude=["tests*", "searxng_extra*"]),
zip_safe=False, zip_safe=False,
install_requires=requirements, install_requires=[
extras_require={ 'certifi==2022.12.7',
'test': dev_requirements 'babel==2.11.0',
}, 'flask-babel==3.0.1',
'flask==2.2.2',
'jinja2==3.1.2',
'lxml==4.9.2',
'pygments==2.14.0',
'python-dateutil==2.8.2',
'pyyaml==6.0',
'httpx[http2]==0.21.2',
'Brotli==1.0.9',
'uvloop==0.17.0',
'httpx-socks[asyncio]==0.7.2',
'setproctitle==1.3.2',
'redis==4.5.1',
'markdown-it-py==2.1.0',
'typing_extensions==4.4.0',
'fasttext-predict==0.9.2.1',
],
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
'searx-run = searx.webapp:run', 'searxng = searx.webapp:run',
'searx-checker = searx.search.checker.__main__:main' 'searxng-checker = searx.search.checker.__main__:main'
] ]
}, },
package_data={ package_data={
'searx': [ 'searx': [
'settings.yml', 'settings.yml',
'../README.rst', '../README.rst',
'../requirements.txt',
'../requirements-dev.txt',
'data/*', 'data/*',
'info/*', 'info/*',
'info/*/*', 'info/*/*',
@ -68,9 +93,6 @@ setup(
'static/*/*/*/*/*.*', 'static/*/*/*/*/*.*',
'templates/*/*.*', 'templates/*/*.*',
'templates/*/*/*.*', 'templates/*/*/*.*',
'tests/*',
'tests/*/*',
'tests/*/*/*',
'translations/*/*/*' 'translations/*/*/*'
], ],
}, },

View file

@ -488,9 +488,6 @@ EOF
info_msg "install needed python packages" info_msg "install needed python packages"
tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix" tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
pip install -U pip pip install -U pip
pip install -U setuptools
pip install -U wheel
pip install -U pyyaml
cd ${SEARXNG_SRC} cd ${SEARXNG_SRC}
pip install -e . pip install -e .
EOF EOF
@ -558,9 +555,6 @@ cd ${SEARXNG_SRC}
git fetch origin "$GIT_BRANCH" git fetch origin "$GIT_BRANCH"
git reset --hard "origin/$GIT_BRANCH" git reset --hard "origin/$GIT_BRANCH"
pip install -U pip pip install -U pip
pip install -U setuptools
pip install -U wheel
pip install -U pyyaml
pip install -U -e . pip install -U -e .
EOF EOF
rst_para "update instance's settings.yml from ${SEARXNG_SETTINGS_PATH}" rst_para "update instance's settings.yml from ${SEARXNG_SETTINGS_PATH}"