check-runtime.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. """Check the local interpreter and standard library, without reading .env."""
  2. import hashlib
  3. import argparse
  4. import sqlite3
  5. import ssl
  6. import sys
  7. from pathlib import Path
  8. def main():
  9. if sys.version_info < (3, 14):
  10. raise RuntimeError("Python >=3.14 is required by this project")
  11. import tomllib
  12. root = Path(__file__).resolve().parents[1]
  13. parser = argparse.ArgumentParser(description=__doc__)
  14. parser.add_argument('--environment', type=Path, default=root / '.venv')
  15. args = parser.parse_args()
  16. if Path(sys.prefix).resolve() != args.environment.resolve():
  17. raise RuntimeError("Unexpected virtual environment interpreter")
  18. with (root / "pyproject.toml").open("rb") as source:
  19. project = tomllib.load(source)["project"]
  20. if project["name"] != "business-assistant":
  21. raise RuntimeError("Unexpected project metadata")
  22. hashlib.sha256(b"runtime-smoke").hexdigest()
  23. with sqlite3.connect(":memory:") as connection:
  24. if connection.execute("select 1").fetchone() != (1,):
  25. raise RuntimeError("SQLite smoke check failed")
  26. if not ssl.OPENSSL_VERSION:
  27. raise RuntimeError("SSL runtime is unavailable")
  28. print(f"Python {sys.version.split()[0]} runtime smoke passed: local venv, TOML, SSL, SQLite, SHA256.")
  29. if __name__ == "__main__":
  30. main()