This commit is contained in:
2026-01-22 12:11:05 -08:00
parent 7a23b3727a
commit a329299b3c
2 changed files with 22 additions and 7 deletions

View File

@@ -137,6 +137,9 @@ def parse_requirements_file(req_path: Path) -> List[str]:
def verify_imports(venv_py: Path, packages: List[str]) -> bool:
# Skip mpv check as it is problematic to install and causes slow startups
packages = [p for p in packages if p.lower() != "mpv"]
# Map some package names to import names (handle common cases where package name differs from import name)
import_map = {
"pyyaml": "yaml",
@@ -150,7 +153,6 @@ def verify_imports(venv_py: Path, packages: List[str]) -> bool:
"service-identity": "service_identity",
"show-in-file-manager": "showinfm",
"opencv-python-headless": "cv2",
"mpv": "mpv",
"pyside6": "PySide6",
}
@@ -1018,16 +1020,29 @@ def main(argv: Optional[List[str]] = None) -> int:
print("Failed to launch client detached:", exc)
return 5
else:
p = None
try:
# If headless on Windows, ensure no window shows even for foreground run
# On Windows, if we are already using pythonw.exe, we don't need CREATE_NO_WINDOW
# as the process already has no console. Avoiding extra flags helps with
# service termination mapping.
kwargs = {}
if os.name == "nt" and headless:
if os.name == "nt" and headless and "pythonw.exe" not in str(venv_py).lower():
kwargs["creationflags"] = 0x08000000
subprocess.run(cmd, cwd=str(cwd), env=env, **kwargs)
return 0
except subprocess.CalledProcessError as e:
print("hydrus client exited non-zero:", e)
p = subprocess.Popen(cmd, cwd=str(cwd), env=env, **kwargs)
p.wait()
return p.returncode
except Exception as e:
if not args.quiet:
print(f"Hydrus client error: {e}")
return 5
finally:
# Ensure the child process is terminated if the monitor process is killed
if p and p.poll() is None:
try:
p.terminate()
except Exception:
pass
if __name__ == "__main__":