mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
feat: add semi-dynamic discovering of build info file
This commit is contained in:
@@ -8,9 +8,22 @@ import platform
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def get_version():
|
def _get_build_info_path() -> (Path | None):
|
||||||
|
current_dir = Path(__file__).resolve().parent
|
||||||
|
|
||||||
|
for _ in range(6): # Climb max 6 directories
|
||||||
|
file = current_dir / "build_info.json"
|
||||||
|
if file.exists():
|
||||||
|
return file
|
||||||
|
# Go up one directory if file isn't found
|
||||||
|
current_dir = current_dir.parent
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_version() -> None:
|
||||||
# Get build info filepath
|
# Get build info filepath
|
||||||
build_info_path = Path(__file__).resolve().parents[4] / "build_info.json" # parents[4] = climb up 5 directories from the file ran
|
build_info_path = _get_build_info_path()
|
||||||
if os.path.exists(build_info_path):
|
if os.path.exists(build_info_path):
|
||||||
with open(build_info_path, "r") as f:
|
with open(build_info_path, "r") as f:
|
||||||
build_info = json.load(f)
|
build_info = json.load(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user