summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Gabaldon <igabaldon@inetol.net>2025-07-23 18:17:58 +0200
committerGitHub <noreply@github.com>2025-07-23 18:17:58 +0200
commitf7c8e4c3535cf03699f9444d3a2b0875bf7a2579 (patch)
treeb6c9e4bd3a4cfbf9733c71e57e9d6bda5c7d8661
parent42f102ce1bbcd76d49db0047d9ad141609eac946 (diff)
[fix] py: overwrite version_frozen on explicit freeze (#5020)
Once version_frozen.py has been created, it will never be updated again unless the file is manually deleted.
-rw-r--r--searx/version.py43
1 files changed, 27 insertions, 16 deletions
diff --git a/searx/version.py b/searx/version.py
index aa6bf91d6..5cacfa210 100644
--- a/searx/version.py
+++ b/searx/version.py
@@ -1,18 +1,19 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=,missing-module-docstring,missing-class-docstring
+import importlib
+import logging
import os
import shlex
import subprocess
-import logging
-import importlib
# fallback values
# if there is searx.version_frozen module, and it is not possible to get the git tag
VERSION_STRING = "1.0.0"
VERSION_TAG = "1.0.0"
-GIT_URL = "unknow"
-GIT_BRANCH = "unknow"
+DOCKER_TAG = "1.0.0"
+GIT_URL = "unknown"
+GIT_BRANCH = "unknown"
logger = logging.getLogger("searx")
@@ -83,6 +84,25 @@ def get_git_version():
return git_version, tag_version, docker_tag
+def get_information():
+ version_string = VERSION_STRING
+ version_tag = VERSION_TAG
+ docker_tag = DOCKER_TAG
+ git_url = GIT_URL
+ git_branch = GIT_BRANCH
+
+ try:
+ version_string, version_tag, docker_tag = get_git_version()
+ except subprocess.CalledProcessError as ex:
+ logger.error("Error while getting the version: %s", ex.stderr)
+ try:
+ git_url, git_branch = get_git_url_and_branch()
+ except subprocess.CalledProcessError as ex:
+ logger.error("Error while getting the git URL & branch: %s", ex.stderr)
+
+ return version_string, version_tag, docker_tag, git_url, git_branch
+
+
try:
vf = importlib.import_module('searx.version_frozen')
VERSION_STRING, VERSION_TAG, DOCKER_TAG, GIT_URL, GIT_BRANCH = (
@@ -93,18 +113,7 @@ try:
vf.GIT_BRANCH,
)
except ImportError:
- try:
- try:
- VERSION_STRING, VERSION_TAG, DOCKER_TAG = get_git_version()
- except subprocess.CalledProcessError as ex:
- logger.error("Error while getting the version: %s", ex.stderr)
- try:
- GIT_URL, GIT_BRANCH = get_git_url_and_branch()
- except subprocess.CalledProcessError as ex:
- logger.error("Error while getting the git URL & branch: %s", ex.stderr)
- except FileNotFoundError as ex:
- logger.error("%s is not found, fallback to the default version", ex.filename)
-
+ VERSION_STRING, VERSION_TAG, DOCKER_TAG, GIT_URL, GIT_BRANCH = get_information()
logger.info("version: %s", VERSION_STRING)
@@ -112,6 +121,8 @@ if __name__ == "__main__":
import sys
if len(sys.argv) >= 2 and sys.argv[1] == "freeze":
+ VERSION_STRING, VERSION_TAG, DOCKER_TAG, GIT_URL, GIT_BRANCH = get_information()
+
# freeze the version (to create an archive outside a git repository)
python_code = f"""# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring