Compilat onefile amb Nuitka (app.py + zstandard) i rutes en mode onefile

This commit is contained in:
2026-05-29 22:52:28 +02:00
parent 667eade660
commit 021e865179
4 changed files with 106 additions and 20 deletions
+11 -3
View File
@@ -1,12 +1,14 @@
"""Resolución de rutas: dónde está games.toml y dónde guardar los datos.
Cuando se compila con Nuitka (``--standalone``) el atributo global ``__compiled__``
existe, así que usamos la carpeta del ejecutable. Ejecutando desde fuente usamos la
raíz del proyecto (la carpeta que contiene el paquete ``jlauncher``).
Compilado con Nuitka, ``__compiled__`` existe. En modo ``--onefile`` la carpeta del
binario real la expone ``NUITKA_ONEFILE_DIRECTORY`` (Nuitka 4.x); con versiones que usan
``NUITKA_ONEFILE_BINARY`` tomamos su carpeta; si no, ``sys.executable`` (standalone).
Ejecutando desde fuente usamos la raíz del proyecto (la carpeta que contiene ``jlauncher``).
"""
from __future__ import annotations
import os
import sys
from pathlib import Path
@@ -21,6 +23,12 @@ def is_compiled() -> bool:
def base_dir() -> Path:
"""Carpeta base junto a la que viven games.toml y jlauncher_data."""
if is_compiled():
directory = os.environ.get("NUITKA_ONEFILE_DIRECTORY")
if directory:
return Path(directory).resolve()
binary = os.environ.get("NUITKA_ONEFILE_BINARY")
if binary:
return Path(binary).resolve().parent
return Path(sys.executable).resolve().parent
# Desde fuente: raíz del proyecto = padre del paquete jlauncher/
return Path(__file__).resolve().parent.parent