YREA-SLS/SLS_Python/sls/meta.py

44 lines
1.2 KiB
Python

# Kyler Olsen
# YREA SLS
# Meta File (Python port)
# November 2025
import sys
from datetime import datetime, timezone
try:
from ._version import commit, timestamp # type: ignore
except ImportError:
try:
import subprocess
result_hash = subprocess.check_output(
["git", "describe", "--always", "--dirty", "--abbrev=7"],
cwd=".",
stderr=subprocess.DEVNULL,
text=True
).strip()
result_date = subprocess.check_output(
["git", "show", "-s", "--format=%ci"],
cwd=".",
stderr=subprocess.DEVNULL,
text=True
).strip()
commit = f"{result_hash} {result_date}"
timestamp = datetime.now(timezone.utc).isoformat() + "Z"
except Exception:
commit = "unknown"
timestamp = "unknown"
# Equivalent of SLS_NAME and SLS_VER
SLS_NAME = "SLS_PYTHON"
SLS_VER = "a.0.0"
# Runtime interpreter info (Python equivalent of compiler)
_impl = sys.implementation
INTERPRETER_NAME = _impl.name.capitalize()
INTERPRETER_VER = _impl.version.major
def print_version() -> None:
print(f"YREA SLS ({SLS_NAME}) {SLS_VER} ({commit})")
print(f"Running on {INTERPRETER_NAME} {INTERPRETER_VER} at {timestamp}")