Fix noconsole crash: redirect None stdout/stderr to devnull on Windows

This commit is contained in:
Jamie Pine
2026-03-15 11:27:35 -07:00
parent e9a249587c
commit 4e4361d350
+8
View File
@@ -6,6 +6,14 @@ absolute imports instead of relative imports.
"""
import sys
import os
# On Windows with --noconsole (PyInstaller), sys.stdout/stderr are None.
# Redirect to devnull to prevent crashes from print()/tqdm/logging.
if sys.stdout is None:
sys.stdout = open(os.devnull, 'w')
if sys.stderr is None:
sys.stderr = open(os.devnull, 'w')
# Fast path: handle --version before any heavy imports so the Rust
# version check doesn't block for 30+ seconds loading torch etc.