From c166bf1c0a6f19693b21964e271f8af9ae7d0a62 Mon Sep 17 00:00:00 2001 From: spark Date: Wed, 28 Oct 2026 16:13:05 +0000 Subject: [PATCH] spark: add Python env health check script --- wizard-work/spark/python-env-check.py | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 wizard-work/spark/python-env-check.py diff --git a/wizard-work/spark/python-env-check.py b/wizard-work/spark/python-env-check.py new file mode 100644 index 0000000..3d00d9c --- /dev/null +++ b/wizard-work/spark/python-env-check.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +"""Python environment health check - verifies key packages are available.""" + +import sys +import json +from datetime import datetime, timezone + +def check_module(name): + try: + __import__(name) + return {"status": "ok", "available": True} + except ImportError as e: + return {"status": "missing", "available": False, "error": str(e)} + +def check_package(name, import_name=None): + import_name = import_name or name + try: + mod = __import__(import_name) + version = getattr(mod, '__version__', 'unknown') + return {"status": "ok", "version": version, "available": True} + except ImportError as e: + return {"status": "missing", "available": False, "error": str(e)} + +def main(): + results = { + "python": { + "status": "ok", + "version": sys.version, + "executable": sys.executable + }, + "packages": { + "json": check_module("json"), + "subprocess": check_module("subprocess"), + "datetime": check_module("datetime"), + } + } + + all_ok = all( + p.get("status") == "ok" or p.get("available", False) + for p in results["packages"].values() + ) + + output = { + "all_ok": all_ok, + "timestamp": datetime.now(timezone.utc).isoformat(), + "components": results + } + + print(json.dumps(output, indent=2)) + sys.exit(0 if all_ok else 1) + +if __name__ == "__main__": + main() \ No newline at end of file