summaryrefslogtreecommitdiff
path: root/utils/build_env.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-07-30 18:57:00 +0200
committerGitHub <noreply@github.com>2021-07-30 18:57:00 +0200
commit38ee88b3905148460e30982715277e7b30857629 (patch)
tree61cf8004cc09fefeffaafb082b8ce86a1c959da4 /utils/build_env.py
parent3b97657f3bbe9bd84a99d46ad1e26391d62ba496 (diff)
parent5b3eeb6e54d4b88adccdf847c32d8102ff6202a5 (diff)
Merge pull request #229 from dalf/version-from-git
version based on git
Diffstat (limited to 'utils/build_env.py')
-rw-r--r--utils/build_env.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/utils/build_env.py b/utils/build_env.py
index dc55bd0a8..0ff99e99f 100644
--- a/utils/build_env.py
+++ b/utils/build_env.py
@@ -10,10 +10,9 @@ from os.path import realpath, dirname, join, sep, abspath
repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
sys.path.insert(0, repo_root)
-# Under the assumption that a brand is always a fork assure that the settings
-# file from reposetorie's working tree is used to generate the build_env, not
-# from /etc/searx/settings.yml.
-os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + sep + 'settings.yml')
+# Assure that the settings file from reposetorie's working tree is used to
+# generate the build_env, not from /etc/searx/settings.yml.
+os.environ['SEARX_SETTINGS_PATH'] = join(repo_root, 'etc', 'settings.yml')
def _env(*arg, **kwargs):
val = get_setting(*arg, **kwargs)
@@ -30,9 +29,6 @@ def _env(*arg, **kwargs):
name_val = [
- ('GIT_URL' , 'brand.git_url'),
- ('GIT_BRANCH' , 'brand.git_branch'),
-
('SEARX_URL' , 'server.base_url'),
('SEARX_PORT' , 'server.port'),
('SEARX_BIND_ADDRESS' , 'server.bind_address'),
@@ -50,15 +46,17 @@ for name, option in name_val:
if not os.environ.get(name, _unset) is _unset:
del os.environ[name]
-# After the variables are unset in the environ, we can import settings
-# (get_setting) from searx module.
+# After the variables are unset in the environ, we can import from the searx
+# package (what will read the values from the settings.yml).
+from searx.version import GIT_URL, GIT_BRANCH
from searx import get_setting
print('build %s (settings from: %s)' % (brand_env, os.environ['SEARX_SETTINGS_PATH']))
sys.path.insert(0, repo_root)
-from searx import settings
with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
for name, option in name_val:
print("export %s='%s'" % (name, _env(option)), file=f)
+ print(f"export GIT_URL='{GIT_URL}'", file=f)
+ print(f"export GIT_BRANCH='{GIT_BRANCH}'", file=f)