preparation for pyinstaller

This commit is contained in:
2026-02-21 11:33:41 +01:00
parent 07dd002c3b
commit bcad8e760b
6 changed files with 30 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ import traceback
def exception_handler(typ_exc, value, trbk):
"""Testium Exception handling"""
print("An unmanaged exception occured", exc_info=(typ_exc, value, trbk))
print("An unmanaged exception occured")
print(f"Critical failure : '{value}'.")
tb = traceback.format_exception(typ_exc, value, trbk)
print("".join(tb))

View File

@@ -1,16 +1,9 @@
import os, sys
import logging
import traceback
logging.basicConfig(
level=logging.ERROR,
filename=os.path.join(os.path.normpath(os.getcwd()), "crash.txt"),
format="%(asctime)s - %(levelname)s - %(message)s"
)
import multiprocessing
def exception_handler(typ_exc, value, trbk):
"""Testium Exception handling"""
logging.error("An unmanaged exception occured", exc_info=(typ_exc, value, trbk))
print(f"Critical failure : '{value}'.")
tb = traceback.format_exception(typ_exc, value, trbk)
print("".join(tb[-4:]))
@@ -22,4 +15,6 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
from testium import main
if __name__ == '__main__':
if getattr(sys, 'frozen', False):
multiprocessing.freeze_support()
main()

View File

@@ -5,7 +5,7 @@ import subprocess
import socket
import libs.testium as tm
from interpreter.utils.paths import testium_path
from interpreter.utils.paths import subproc_path
from interpreter.utils.tum_except import ETUMRuntimeError
from interpreter.utils.jrpc import JsonRpcClient
from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win
@@ -58,6 +58,7 @@ def _sys_lua_bin():
tm.print_debug(f"'{sys_lua_bin}' not a lua 5.1 min.")
sys_lua_bin = ""
tm.print_debug(f"lua bin is: '{sys_lua_bin}'.")
tm.setgd("_sys_lua_bin", sys_lua_bin)
return sys_lua_bin
@@ -145,7 +146,7 @@ class LuaProcessBase:
raise ETUMRuntimeError("The function subprocess has already been started.")
func_proc_path = os.path.realpath(
os.path.join(testium_path(), "..", "lua_func")
os.path.join(subproc_path(), "lua_func")
)
# POpen config

View File

@@ -9,9 +9,23 @@ import libs.testium as tm
def testium_path():
if getattr(sys, 'frozen', False):
# Exécuté depuis le .exe
print(f"Path: {sys._MEIPASS}")
return sys._MEIPASS
tp = inspect.getfile(inspect.getmodule(testium))
return str(Path(tp).parent.resolve())
def subproc_path():
if getattr(sys, 'frozen', False):
# Exécuté depuis le .exe
print(f"Path: {sys._MEIPASS}")
return sys._MEIPASS
tp = inspect.getfile(inspect.getmodule(testium))
return str(Path(tp).parent.parent.resolve())
def prepare_file_to_save(file_name, file_ext=""):
iname = file_name

View File

@@ -7,7 +7,7 @@ import libs.testium as tm
from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win
from interpreter.utils.tum_except import ETUMRuntimeError
from interpreter.utils.jrpc import JsonRpcClient
from interpreter.utils.paths import testium_path
from interpreter.utils.paths import testium_path, subproc_path
def _python_version(path: str):
@@ -71,6 +71,7 @@ def _sys_python_bin():
break
sys_python_bin = ""
tm.print_debug(f"python bin is: '{sys_python_bin}'.")
return sys_python_bin
@@ -141,8 +142,9 @@ class PyProcessBase:
sock.close()
# Add the path of the subprocess (root sources of testium)
func_proc_path = os.path.realpath(os.path.join(testium_path(), ".."))
env["PYTHONPATH"] = func_proc_path + os.pathsep + self._ppath + os.pathsep + env.get("PYTHONPATH", "")
tstium_path = os.path.realpath(testium_path())
func_proc_path = os.path.realpath(subproc_path())
env["PYTHONPATH"] = tstium_path + os.pathsep + self._ppath + os.pathsep + env.get("PYTHONPATH", "")
params = [
self._pbin,

View File

@@ -7,7 +7,7 @@ from PySide6.QtWidgets import QDialog
from PySide6.QtGui import QSyntaxHighlighter, QTextCharFormat, QColor, QFont, QDesktopServices
from PySide6.QtCore import Qt, QUrl
from testium.main_win.f1_win.f1_win_core import Ui_F1Dialog
from main_win.f1_win.f1_win_core import Ui_F1Dialog
class YamlHighlighter(QSyntaxHighlighter):