From fb65f4f249a9a715dbb52242fd98217262cb3840 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 30 May 2026 22:01:46 +0200 Subject: [PATCH] Afig directoris de Homebrew al PATH i puja a 1.0.2 --- jlauncher/__init__.py | 2 +- jlauncher/runner.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/jlauncher/__init__.py b/jlauncher/__init__.py index 15123ae..ee89fcc 100644 --- a/jlauncher/__init__.py +++ b/jlauncher/__init__.py @@ -1,3 +1,3 @@ """jlauncher — lanzador de juegos jailgames.""" -__version__ = "1.0.1" +__version__ = "1.0.2" diff --git a/jlauncher/runner.py b/jlauncher/runner.py index a39317c..1060673 100644 --- a/jlauncher/runner.py +++ b/jlauncher/runner.py @@ -2,6 +2,7 @@ from __future__ import annotations +import os import subprocess from collections.abc import Callable from pathlib import Path @@ -11,11 +12,38 @@ from .paths import repo_dir LogFn = Callable[[str], None] +# 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 +# (Apple Silicon) o /usr/local/bin (Intel), quedan fuera del PATH y `make` no las +# encuentra. Las añadimos explícitamente. En Linux estos paths no existen y se +# filtran solos. +_EXTRA_PATH_DIRS = ( + "/opt/homebrew/bin", + "/opt/homebrew/sbin", + "/usr/local/bin", + "/usr/local/sbin", + "/opt/local/bin", +) + def _noop(_: str) -> None: pass +def _launch_env() -> dict[str, str]: + """Entorno para los subprocesos con un PATH que incluye los directorios de + herramientas habituales aunque la app se lance desde Finder/Dock.""" + env = os.environ.copy() + parts = env.get("PATH", "").split(os.pathsep) + parts = [p for p in parts if p] + for d in _EXTRA_PATH_DIRS: + if d not in parts and os.path.isdir(d): + parts.append(d) + env["PATH"] = os.pathsep.join(parts) + return env + + def _stream(cmd: str, cwd: Path, log: LogFn) -> int: """Ejecuta un comando de shell en cwd, retransmitiendo stdout/err línea a línea.""" log(f"$ {cmd} (cwd={cwd})") @@ -27,6 +55,7 @@ def _stream(cmd: str, cwd: Path, log: LogFn) -> int: stderr=subprocess.STDOUT, text=True, bufsize=1, + env=_launch_env(), ) assert proc.stdout is not None for line in proc.stdout: