import sys import subprocess try: import streamlit as st except Exception: # pragma: no cover st = None def commit_hash() -> str: """Return current git commit hash or '' if unavailable.""" try: return subprocess.check_output(["git", "rev-parse", "HEAD"], shell=False, encoding="utf-8").strip() except Exception: return "" def versions_html() -> str: """Return a small HTML snippet with runtime and app environment info. Includes: git commit, Python version, and Streamlit version. """ python_version = ".".join(str(x) for x in sys.version_info[:3]) full_python = sys.version.replace("\n", " ") commit = commit_hash() streamlit_version = getattr(st, "__version__", "not installed") html = f"""
commit: {commit}  |  python: {python_version}  |  streamlit: {streamlit_version}
""" return html