From e60c3cc6eb15fd0c997be6653c136ef8319bbe17 Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Mon, 1 Jun 2026 12:58:59 +0200 Subject: [PATCH] Evita finestres de consola a Windows als subprocessos (CREATE_NO_WINDOW) --- jlauncher/gitops.py | 7 +++++++ jlauncher/runner.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/jlauncher/gitops.py b/jlauncher/gitops.py index cfddd89..4a04287 100644 --- a/jlauncher/gitops.py +++ b/jlauncher/gitops.py @@ -46,6 +46,11 @@ class NetConfig: DEFAULT_NET = NetConfig() +# Windows: evita que cada `git` (aplicación de consola) abra una ventana negra +# cuando el lanzador corre como GUI sin consola (el .exe compilado con Nuitka +# --windows-console-mode=disable). En el resto de SO es 0 (sin efecto). +_NO_WINDOW = subprocess.CREATE_NO_WINDOW if sys.platform == "win32" else 0 + def _noop(_: str) -> None: pass @@ -126,6 +131,7 @@ def _run_git( text=True, env={**os.environ, "GIT_TERMINAL_PROMPT": "0"}, timeout=timeout, + creationflags=_NO_WINDOW, ) except subprocess.TimeoutExpired: emit( @@ -299,6 +305,7 @@ def _read_version(game: Game, repo: Path, log: LogFn) -> str: capture_output=True, text=True, timeout=20, + creationflags=_NO_WINDOW, ) except (OSError, subprocess.SubprocessError) as exc: log(f"version_cmd ha fallat: {exc}") diff --git a/jlauncher/runner.py b/jlauncher/runner.py index f602be8..12aeaad 100644 --- a/jlauncher/runner.py +++ b/jlauncher/runner.py @@ -4,6 +4,7 @@ from __future__ import annotations import os import subprocess +import sys from collections.abc import Callable from pathlib import Path @@ -12,6 +13,11 @@ from .paths import repo_dir LogFn = Callable[[str], None] +# Windows: evita que la compilación/ejecución (shell + make/gcc, apps de consola) +# abra ventanas negras cuando el lanzador corre como GUI sin consola (el .exe). +# En el resto de SO es 0 (sin efecto). +_NO_WINDOW = subprocess.CREATE_NO_WINDOW if sys.platform == "win32" else 0 + # Directorios habituales de herramientas de línea de comandos (Homebrew, MacPorts…). # Una .app de macOS lanzada desde Finder/Dock NO hereda el PATH del shell de login, # así que herramientas como cmake, instaladas con Homebrew en /opt/homebrew/bin @@ -90,6 +96,7 @@ def _stream(cmd: str, cwd: Path, log: LogFn) -> int: text=True, bufsize=1, env=_launch_env(), + creationflags=_NO_WINDOW, ) assert proc.stdout is not None for line in proc.stdout: