on engine-data help sign in
searx/utils/build_env.py
38 lines 1.4 kB history raw
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""build environment used by shell scripts
3"""
5# set path
6import sys
7import os
8from os.path import realpath, dirname, join, sep, abspath
10repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
11sys.path.insert(0, repo_root)
12os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + '/settings.yml')
14# Under the assumption that a brand is always a fork assure that the settings
15# file from reposetorie's working tree is used to generate the build_env, not
16# from /etc/searx/settings.yml.
17os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + sep + 'settings.yml')
19from searx import brand
21name_val = [
22 ('SEARX_URL' , brand.SEARX_URL),
23 ('GIT_URL' , brand.GIT_URL),
24 ('GIT_BRANCH' , brand.GIT_BRANCH),
25 ('ISSUE_URL' , brand.ISSUE_URL),
26 ('DOCS_URL' , brand.DOCS_URL),
27 ('PUBLIC_INSTANCES' , brand.PUBLIC_INSTANCES),
28 ('CONTACT_URL' , brand.CONTACT_URL),
29 ('WIKI_URL' , brand.WIKI_URL),
30 ('TWITTER_URL' , brand.TWITTER_URL),
33brand_env = 'utils' + sep + 'brand.env'
35print('build %s' % brand_env)
36with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
37 for name, val in name_val:
38 print("export %s='%s'" % (name, val), file=f)