old_updater_main.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. """Frozen main.py imports for updater code still running after a checkout swap.
  2. These are not the live helpers in main_desktop, main_install_repair or
  3. main_web_build. Returning from an old installer can trigger a retry or report
  4. success, so those call paths stop for relaunch instead.
  5. """
  6. from pathlib import Path
  7. from typing import NoReturn
  8. from hermes_cli._old_updater import stop_for_relaunch
  9. # Shim to stop the old updater doing work until relaunch. Retain the filename
  10. # as data only, without recording a fingerprint or replacing the live recorder.
  11. _BYTECODE_FINGERPRINT_FILE = ".bytecode-fingerprint"
  12. class ShimQuarantineError(RuntimeError):
  13. # Shim to stop the old updater doing work until relaunch. Preserve the
  14. # historical exception payload without performing or claiming quarantine.
  15. def __init__(self, failed_shims: list[str]):
  16. self.failed_shims = list(failed_shims)
  17. super().__init__("could not quarantine live shim(s): " + ", ".join(self.failed_shims))
  18. def _desktop_stamp_path() -> NoReturn:
  19. # Shim to stop the old updater doing work until relaunch, not select a build stamp.
  20. stop_for_relaunch()
  21. def _detect_broken_lazy_refresh_imports(
  22. install_cmd_prefix: list[str], *, env: dict[str, str] | None = None,
  23. ) -> None:
  24. # Shim to stop the old updater doing work until relaunch: unknown, not healthy [].
  25. return None
  26. def _expected_windows_pe_machines() -> NoReturn:
  27. # Shim to stop the old updater doing work until relaunch, not approve a binary.
  28. stop_for_relaunch()
  29. def _hermes_exe_shims(scripts_dir: Path) -> NoReturn:
  30. # Shim to stop the old updater doing work until relaunch, not select files to rename.
  31. stop_for_relaunch()
  32. def _insert_python_pin(args: list[str]) -> NoReturn:
  33. # Shim to stop the old updater doing work until relaunch, not prepare an install.
  34. stop_for_relaunch()
  35. def _interpreter_scripts_dir() -> NoReturn:
  36. # Shim to stop the old updater doing work until relaunch, not target live launchers.
  37. stop_for_relaunch()
  38. def _load_installable_optional_extras(group: str = "all") -> NoReturn:
  39. # Shim to stop the old updater doing work until relaunch, not select dependency retries.
  40. stop_for_relaunch()
  41. def _parse_pe_machine(path: Path) -> NoReturn:
  42. # Shim to stop the old updater doing work until relaunch, not trigger a binary fallback.
  43. stop_for_relaunch()
  44. def _quarantine_running_hermes_exe(
  45. scripts_dir: Path, *, max_attempts: int = 4, failed_out: list[str] | None = None,
  46. ) -> NoReturn:
  47. # Shim to stop the old updater doing work until relaunch, not rename live executables.
  48. stop_for_relaunch()
  49. def _repair_broken_lazy_refresh_imports(
  50. install_cmd_prefix: list[str], packages: list[str], *, env: dict[str, str] | None = None,
  51. ) -> NoReturn:
  52. # Shim to stop the old updater doing work until relaunch, not repair or claim health.
  53. stop_for_relaunch()
  54. def _resolve_install_target_python(
  55. install_cmd_prefix: list[str], env: dict[str, str] | None,
  56. ) -> None:
  57. # Shim to stop the old updater doing work until relaunch: no interpreter to probe.
  58. return None
  59. def _restore_quarantined_exes(moved: list[tuple[Path, Path]]) -> None:
  60. # Shim to stop the old updater doing work until relaunch, including finally-block renames.
  61. return None
  62. def _run_install_with_heartbeat(
  63. cmd: list[str], *, env: dict[str, str] | None = None, heartbeat_interval_seconds: int = 30,
  64. ) -> NoReturn:
  65. # Shim to stop the old updater doing work until relaunch, not run pip/uv or report success.
  66. stop_for_relaunch()
  67. def _run_package_only_install(cmd: list[str], *, env: dict[str, str] | None = None) -> NoReturn:
  68. # Shim to stop the old updater doing work until relaunch, not run a package-only retry.
  69. stop_for_relaunch()
  70. def _run_quarantined_install(
  71. cmd: list[str], *, env: dict[str, str] | None = None, scripts_dir: Path | None = None,
  72. strict_quarantine: bool = False,
  73. ) -> NoReturn:
  74. # Shim to stop the old updater doing work until relaunch, not install or enable fallback.
  75. stop_for_relaunch()
  76. def _run_with_idle_timeout(
  77. cmd: list[str], cwd: Path, *, idle_timeout_seconds: int = 180, indent: str = " ",
  78. env: dict[str, str] | None = None,
  79. ) -> NoReturn:
  80. # Shim to stop the old updater doing work until relaunch, not build or synthesize success.
  81. stop_for_relaunch()
  82. def _self() -> NoReturn:
  83. # Shim to stop the old updater doing work until relaunch, not expose live process scans.
  84. stop_for_relaunch()
  85. def _verify_console_scripts_installed(
  86. install_cmd_prefix: list[str], *, env: dict[str, str] | None = None,
  87. ) -> NoReturn:
  88. # Shim to stop the old updater doing work until relaunch, not reinstall entry points.
  89. stop_for_relaunch()
  90. def _verify_core_dependencies_installed(
  91. install_cmd_prefix: list[str], *, env: dict[str, str] | None = None, group: str = "all",
  92. ) -> NoReturn:
  93. # Shim to stop the old updater doing work until relaunch, not reinstall missing packages.
  94. stop_for_relaunch()
  95. def _web_ui_build_needed(web_dir: Path) -> NoReturn:
  96. # Shim to stop the old updater doing work until relaunch, not claim an unbuilt UI is current.
  97. stop_for_relaunch()
  98. def _windows_native_machine() -> NoReturn:
  99. # Shim to stop the old updater doing work until relaunch, not approve a fallback architecture.
  100. stop_for_relaunch()
  101. def _windows_shim_in_process_chain() -> NoReturn:
  102. # Shim to stop the old updater doing work until relaunch, not spawn an install handoff.
  103. stop_for_relaunch()
  104. def _write_web_ui_build_stamp(project_root: Path, web_dir: Path) -> None:
  105. # Shim to stop the old updater doing work until relaunch. Never write a success marker.
  106. return None