mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-15 03:32:43 +08:00
fix: 修復 win python install.py
This commit is contained in:
21
install.py
21
install.py
@@ -357,6 +357,27 @@ def op_run_command(op: Dict[str, Any], ctx: Dict[str, Any]) -> None:
|
|||||||
stderr_lines: List[str] = []
|
stderr_lines: List[str] = []
|
||||||
|
|
||||||
# Read stdout and stderr in real-time
|
# Read stdout and stderr in real-time
|
||||||
|
if sys.platform == "win32":
|
||||||
|
# On Windows, use threads instead of selectors (pipes aren't selectable)
|
||||||
|
import threading
|
||||||
|
|
||||||
|
def read_output(pipe, lines, file=None):
|
||||||
|
for line in iter(pipe.readline, ''):
|
||||||
|
lines.append(line)
|
||||||
|
print(line, end="", flush=True, file=file)
|
||||||
|
pipe.close()
|
||||||
|
|
||||||
|
stdout_thread = threading.Thread(target=read_output, args=(process.stdout, stdout_lines))
|
||||||
|
stderr_thread = threading.Thread(target=read_output, args=(process.stderr, stderr_lines, sys.stderr))
|
||||||
|
|
||||||
|
stdout_thread.start()
|
||||||
|
stderr_thread.start()
|
||||||
|
|
||||||
|
stdout_thread.join()
|
||||||
|
stderr_thread.join()
|
||||||
|
process.wait()
|
||||||
|
else:
|
||||||
|
# On Unix, use selectors for more efficient I/O
|
||||||
import selectors
|
import selectors
|
||||||
sel = selectors.DefaultSelector()
|
sel = selectors.DefaultSelector()
|
||||||
sel.register(process.stdout, selectors.EVENT_READ) # type: ignore[arg-type]
|
sel.register(process.stdout, selectors.EVENT_READ) # type: ignore[arg-type]
|
||||||
|
|||||||
Reference in New Issue
Block a user