Afig directoris de Homebrew al PATH i puja a 1.0.2

This commit is contained in:
2026-05-30 22:01:46 +02:00
parent be8c886ad1
commit fb65f4f249
2 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""jlauncher — lanzador de juegos jailgames."""
__version__ = "1.0.1"
__version__ = "1.0.2"
+29
View File
@@ -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: