build_env.py 1.2 KB

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