diff --git a/wizard-work/spark/env-verify.py b/wizard-work/spark/env-verify.py new file mode 100644 index 0000000..5a87ba6 --- /dev/null +++ b/wizard-work/spark/env-verify.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +""" +Environment verification script. +Produces a manifest file with verifiable facts. +""" +import subprocess +import hashlib +import json +import sys +from pathlib import Path + +def get_sha256(text: str) -> str: + return hashlib.sha256(text.encode()).hexdigest() + +def run_cmd(cmd: str) -> tuple[str, str]: + result = subprocess.run(cmd, shell=True, capture_output=True, text=True) + return result.stdout.strip(), result.stderr.strip() + +def main(): + manifest = {} + + # Python version + py_ver, _ = run_cmd("python3 --version") + manifest["python_version"] = py_ver + manifest["python_version_hash"] = get_sha256(py_ver) + + # Pip version + pip_ver, _ = run_cmd("pip --version") + manifest["pip_version"] = pip_ver + manifest["pip_version_hash"] = get_sha256(pip_ver) + + # Python executable path + py_path, _ = run_cmd("which python3") + manifest["python_path"] = py_path + manifest["python_path_hash"] = get_sha256(py_path) + + # Verify pip module is importable + try: + import pip + manifest["pip_module_importable"] = True + manifest["pip_module_version"] = pip.__version__ + manifest["pip_module_version_hash"] = get_sha256(pip.__version__) + except ImportError as e: + manifest["pip_module_importable"] = False + manifest["pip_import_error"] = str(e) + + # Write manifest + output_path = Path("/root/.hermes/wizard-outputs/spark/manifest.json") + with open(output_path, "w") as f: + json.dump(manifest, f, indent=2) + + print(f"Manifest written to {output_path}") + print(json.dumps(manifest, indent=2)) + + # Verify expected values + assert "Python 3.14.7" in manifest["python_version"], f"Unexpected Python version: {manifest['python_version']}" + assert manifest["python_path"].endswith("python3"), f"Unexpected Python path: {manifest['python_path']}" + assert manifest["pip_module_importable"] == True, "pip module not importable" + + print("\nAll verifications passed!", file=sys.stderr) + return 0 + +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file diff --git a/wizard-work/spark/manifest.json b/wizard-work/spark/manifest.json new file mode 100644 index 0000000..4b231c4 --- /dev/null +++ b/wizard-work/spark/manifest.json @@ -0,0 +1,11 @@ +{ + "python_version": "Python 3.14.7", + "python_version_hash": "ed1f174a19c07f234e67c8b3f6a0e42f09a361221546ffa9af1a1aff0347150f", + "pip_version": "pip 26.2.1 from /root/.hermes/installs/76f6e7e5145b5f39/environments/c5b879e2036d4c909805dd1858587925/venv/lib/python3.14/site-packages/pip (python 3.14)", + "pip_version_hash": "74f531662a29b482dbe6b216c0fac8078df2ceb3004b6e0a527e734184a201b6", + "python_path": "/root/.hermes/installs/76f6e7e5145b5f39/environments/c5b879e2036d4c909805dd1858587925/venv/bin/python3", + "python_path_hash": "4bedb0a1ce4c24ef46fca885e5f7332de59d41fce29362732d07d9a039b98606", + "pip_module_importable": true, + "pip_module_version": "26.2.1", + "pip_module_version_hash": "a64c385c1c037ad7e56e1491800233ae116b48c12f6f23be183fb8d0f21c5e73" +} \ No newline at end of file