diff --git a/jlauncher/__init__.py b/jlauncher/__init__.py index ee89fcc..1b2e450 100644 --- a/jlauncher/__init__.py +++ b/jlauncher/__init__.py @@ -1,3 +1,3 @@ """jlauncher — lanzador de juegos jailgames.""" -__version__ = "1.0.2" +__version__ = "1.0.3" diff --git a/jlauncher/runner.py b/jlauncher/runner.py index 1060673..f602be8 100644 --- a/jlauncher/runner.py +++ b/jlauncher/runner.py @@ -26,6 +26,17 @@ _EXTRA_PATH_DIRS = ( "/opt/local/bin", ) +# Prefijos de Homebrew/MacPorts. Una .app lanzada desde Finder/Dock tampoco +# hereda CPATH/LIBRARY_PATH/PKG_CONFIG_PATH del shell, así que el compilador no +# encuentra las cabeceras (p.ej. ) ni las librerías +# instaladas con `brew`. Añadimos sus include/lib explícitamente. En Linux estos +# paths no existen y se filtran solos. +_EXTRA_PREFIXES = ( + "/opt/homebrew", + "/usr/local", + "/opt/local", +) + def _noop(_: str) -> None: pass @@ -41,9 +52,32 @@ def _launch_env() -> dict[str, str]: if d not in parts and os.path.isdir(d): parts.append(d) env["PATH"] = os.pathsep.join(parts) + + # Rutas de cabeceras (CPATH), librerías (LIBRARY_PATH) y pkg-config para que + # el compilador encuentre dependencias instaladas con brew/MacPorts. + includes, libs, pkgconfigs = [], [], [] + for prefix in _EXTRA_PREFIXES: + inc, lib = f"{prefix}/include", f"{prefix}/lib" + if os.path.isdir(inc): + includes.append(inc) + if os.path.isdir(lib): + libs.append(lib) + pkgconfigs.append(f"{lib}/pkgconfig") + _prepend(env, "CPATH", includes) + _prepend(env, "LIBRARY_PATH", libs) + _prepend(env, "PKG_CONFIG_PATH", pkgconfigs) return env +def _prepend(env: dict[str, str], var: str, dirs: list[str]) -> None: + """Antepone dirs al valor de env[var] (lista separada por os.pathsep), sin + duplicar entradas ya presentes.""" + existing = [p for p in env.get(var, "").split(os.pathsep) if p] + new = [d for d in dirs if d not in existing] + if new: + env[var] = os.pathsep.join(new + existing) + + 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})") diff --git a/pyproject.toml b/pyproject.toml index 7d5e6af..9d99b8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "jlauncher" -version = "1.0.1" +version = "1.0.3" description = "Lanzador de juegos jailgames: clona, compila y ejecuta repos Gitea" requires-python = ">=3.11" dependencies = [