попытка перехода на python 3.12 и nutika для компиляции без зависимостей

This commit is contained in:
Razvalyaev 2025-07-09 19:07:27 +03:00
parent f881132fa8
commit 3343428796
148 changed files with 306880 additions and 1811 deletions

Binary file not shown.

View File

@ -458,8 +458,16 @@ class VariableSelectorDialog(QDialog):
set_text('show_var', 'false')
set_text('enable', 'false')
ET.indent(tree, space=" ", level=0)
tree.write(self.xml_path, encoding='utf-8', xml_declaration=True)
# Преобразуем дерево в строку
rough_string = ET.tostring(root, encoding="utf-8")
# Парсим и форматируем с отступами
reparsed = minidom.parseString(rough_string)
pretty_xml = reparsed.toprettyxml(indent=" ")
# Записываем в файл
with open(self.xml_path, "w", encoding="utf-8") as f:
f.write(pretty_xml)
self.populate_tree()
self.accept()
@ -509,8 +517,16 @@ class VariableSelectorDialog(QDialog):
self.all_vars[:] = [v for v in self.all_vars if v['name'] not in selected_names]
if removed_any:
ET.indent(tree, space=" ", level=0)
tree.write(self.xml_path, encoding='utf-8', xml_declaration=True)
# Преобразуем дерево в строку
rough_string = ET.tostring(root, encoding="utf-8")
# Парсим и форматируем с отступами
reparsed = minidom.parseString(rough_string)
pretty_xml = reparsed.toprettyxml(indent=" ")
# Записываем в файл
with open(self.xml_path, "w", encoding="utf-8") as f:
f.write(pretty_xml)
self.populate_tree()
self.filter_tree()

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -8,6 +8,7 @@ import os
import re
import xml.etree.ElementTree as ET
from pathlib import Path
from xml.dom import minidom
import argparse
@ -214,8 +215,16 @@ def add_new_vars_to_xml(proj_path, xml_rel_path, output_path):
added_count += 1
if added_count > 0:
ET.indent(tree, space=" ", level=0)
tree.write(xml_full_path, encoding="utf-8", xml_declaration=True)
# Преобразуем дерево в строку
rough_string = ET.tostring(root, encoding="utf-8")
# Парсим и форматируем с отступами
reparsed = minidom.parseString(rough_string)
pretty_xml = reparsed.toprettyxml(indent=" ")
# Записываем в файл
with open(xml_full_path, "w", encoding="utf-8") as f:
f.write(pretty_xml)
print(f"[INFO] В XML добавлено новых переменных: {added_count}")
return True
else:

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -93,9 +93,16 @@ def parse_vars(filename, typedef_map=None):
'static': var.findtext('static', 'false') == 'true',
})
ET.indent(tree, space=" ", level=0)
# Сохраняем изменения в XML-файл
tree.write(filename, encoding='utf-8', xml_declaration=True)
# Преобразуем дерево в строку
rough_string = ET.tostring(root, encoding="utf-8")
# Парсим и форматируем с отступами
reparsed = minidom.parseString(rough_string)
pretty_xml = reparsed.toprettyxml(indent=" ")
# Записываем в файл
with open(filename, "w", encoding="utf-8") as f:
f.write(pretty_xml)
return vars_list

View File

@ -18,7 +18,7 @@ from PySide6.QtWidgets import (
QApplication, QWidget, QTableWidget, QTableWidgetItem,
QCheckBox, QComboBox, QLineEdit, QVBoxLayout, QHBoxLayout, QPushButton,
QCompleter, QAbstractItemView, QLabel, QMessageBox, QFileDialog, QTextEdit,
QDialog, QTreeWidget, QTreeWidgetItem, QSizePolicy
QDialog, QTreeWidget, QTreeWidgetItem, QSizePolicy, QHeaderView
)
from PySide6.QtGui import QTextCursor, QKeyEvent
from PySide6.QtCore import Qt, QProcess, QObject, Signal, QSettings
@ -561,9 +561,16 @@ class VarEditor(QWidget):
set_sub_elem_text(var_elem, 'extern', extern_val)
set_sub_elem_text(var_elem, 'static', static_val)
# Преобразуем дерево в строку
rough_string = ET.tostring(root, encoding="utf-8")
ET.indent(tree, space=" ", level=0)
tree.write(self.xml_path, encoding='utf-8', xml_declaration=True)
# Парсим и форматируем с отступами
reparsed = minidom.parseString(rough_string)
pretty_xml = reparsed.toprettyxml(indent=" ")
# Записываем в файл
with open(self.xml_path, "w", encoding="utf-8") as f:
f.write(pretty_xml)
except Exception as e:
print(f"Ошибка при сохранении XML: {e}")

View File

@ -1,34 +1,119 @@
import subprocess
import shutil
import os
import PySide6
# Пути
dist_path = os.path.abspath("./") # текущая папка — exe будет тут
work_path = os.path.abspath("./build_temp")
spec_path = os.path.abspath("./build_temp")
USE_NUITKA = True # переключатель: True — сборка через Nuitka, False — через PyInstaller
pyside6_path = os.path.dirname(PySide6.__file__)
plugins_platforms_path = os.path.join(pyside6_path, "plugins", "platforms")
dist_path = os.path.abspath(".") # итоговая папка с exe
work_path = os.path.abspath("./build_temp") # временная папка для PyInstaller
spec_path = os.path.abspath("./build_temp") # папка exдля spec-файлов PyInstaller
script_dir = os.path.dirname(os.path.abspath(__file__))
libclang_path = os.path.join(script_dir, "libclang.dll")
libssl_orig = os.path.join(script_dir, "libssl-3-x64.dll")
libcrypto_orig = os.path.join(script_dir, "libcrypto-3-x64.dll")
# Запуск PyInstaller с нужными параметрами
cmd = [
"pyinstaller",
"--onefile",
"--windowed",
"--name", "DebugVarEdit",
"--add-binary", f"{libclang_path};.",
"--distpath", dist_path,
"--workpath", work_path,
"--specpath", spec_path,
"./Src/setupVars_GUI.py"
]
# Собираем бинарники и данные для PyInstaller
add_binary_list = [f"{libclang_path};."]
if os.path.exists(libssl_orig):
add_binary_list.append(f"{libssl_orig};libssl.dll")
else:
print("WARNING: libssl-3-x64.dll не найден, OpenSSL не будет включён")
if os.path.exists(libcrypto_orig):
add_binary_list.append(f"{libcrypto_orig};libcrypto.dll")
else:
print("WARNING: libcrypto-3-x64.dll не найден, OpenSSL не будет включён")
from PyInstaller.utils.hooks import collect_data_files
datas = []
datas += collect_data_files('PySide6', includes=['plugins/platforms/*'])
datas += collect_data_files('PySide6', includes=['plugins/styles/*'])
datas += collect_data_files('PySide6', includes=['plugins/imageformats/*'])
add_data_list = [f"{src};{dest}" for src, dest in datas]
script_path = "./Src/setupVars_GUI.py"
output_name = "DebugVarEdit"
env = os.environ.copy()
env["CC"] = r"C:\Users\I\AppData\Local\Nuitka\Nuitka\Cache\DOWNLOADS\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2\bin\gcc.exe"
env["CXX"] = r"C:\Users\I\AppData\Local\Nuitka\Nuitka\Cache\DOWNLOADS\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2\bin\g++.exe"
if not USE_NUITKA:
# PyInstaller команда
cmd = [
"pyinstaller",
"--onefile",
"--name", output_name,
*[item for add_bin in add_binary_list for item in ("--add-binary", add_bin)],
*[item for add_dat in add_data_list for item in ("--add-data", add_dat)],
"--distpath", dist_path,
"--workpath", work_path,
"--specpath", spec_path,
"--hidden-import", "PySide6.QtWidgets",
"--hidden-import", "PySide6.QtGui",
"--hidden-import", "PySide6.QtCore",
"--windowed",
script_path
]
else:
# Nuitka команда
# Формируем --include-data-dir для плагинов PySide6 (datas как в PyInstaller)
# Было — неправильный способ: передаёт файлы
plugin_dirs = set()
for src, dest in datas:
src_dir = os.path.dirname(src)
dest_root = dest.split("/", 1)[0] if "/" in dest else dest
plugin_dirs.add((src_dir, dest_root))
include_data_dirs = [
f"--include-data-dir={src}={dest}" for src, dest in plugin_dirs
]
include_data_files = []
for dll_path, dll_name in [(libclang_path, "libclang.dll"),
(libssl_orig, "libssl.dll"),
(libcrypto_orig, "libcrypto.dll")]:
if os.path.exists(dll_path):
include_data_files.append(f"--include-data-file={dll_path}={dll_name}")
cmd = [
"python", "-m", "nuitka",
"--standalone", # полностью независимый билд (аналог PyInstaller --onefile/--onedir)
"--onefile", # упаковать в один exe (экспериментально)
"--enable-plugin=pyside6",
"--windows-console-mode=disable",
f"--output-dir={dist_path}",
f"--output-filename={output_name}.exe",
] + include_data_dirs + [
script_path
]
# Удаляем временные папки, если они у тебя есть
temp_dirs = ["build_temp", "__pycache__"] # добавь свои папки с временными файлами
for d in temp_dirs:
if os.path.exists(d):
shutil.rmtree(d)
print("Выполняется сборка:")
print(" ".join(cmd))
result = subprocess.run(cmd, env=env)
result = subprocess.run(cmd)
if result.returncode == 0:
# Удаляем временные папки
for folder in ["build_temp", "__pycache__"]:
if os.path.exists(folder):
shutil.rmtree(folder)
# Чистим временные папки, только для PyInstaller (для Nuitka обычно не нужно)
if not USE_NUITKA:
for folder in ["build_temp", "__pycache__"]:
if os.path.exists(folder):
shutil.rmtree(folder)
print("Сборка успешно завершена!")
else:
print("Сборка завершилась с ошибкой.")

BIN
build/libcrypto-3-x64.dll Normal file

Binary file not shown.

BIN
build/libssl-3-x64.dll Normal file

Binary file not shown.

View File

@ -3,34 +3,34 @@
// Èíêëþäû äëÿ äîñòóïà ê ïåðåìåííûì
#include "vector.h"
#include "RS_Functions_modbus.h"
#include "adc_tools.h"
#include "errors.h"
#include "v_pwm24.h"
#include "f281xpwm.h"
#include "xp_project.h"
#include "rotation_speed.h"
#include "teta_calc.h"
#include "vector.h"
#include "dq_to_alphabeta_cos.h"
#include "xp_write_xpwm_time.h"
#include "log_can.h"
#include "teta_calc.h"
#include "v_pwm24.h"
#include "errors.h"
#include "pwm_vector_regul.h"
#include "xp_project.h"
#include "xp_write_xpwm_time.h"
#include "rotation_speed.h"
#include "f281xpwm.h"
#include "adc_tools.h"
#include "log_can.h"
#include "RS_Functions.h"
#include "detect_phase_break2.h"
#include "svgen_dq.h"
#include "x_parallel_bus.h"
#include "Spartan2E_Functions.h"
#include "detect_phase_break2.h"
#include "pid_reg3.h"
#include "xp_rotation_sensor.h"
#include "x_serial_bus.h"
#include "xp_controller.h"
#include "xp_rotation_sensor.h"
#include "Spartan2E_Functions.h"
#include "xPeriphSP6_loader.h"
#include "log_to_memory.h"
#include "global_time.h"
#include "CAN_Setup.h"
#include "log_params.h"
#include "x_parallel_bus.h"
#include "CRC_Functions.h"
#include "pid_reg3.h"
#include "log_params.h"
#include "CAN_Setup.h"
#include "global_time.h"
#include "log_to_memory.h"
#include "IQmathLib.h"
#include "doors_control.h"
#include "isolation.h"
@ -317,5 +317,5 @@ extern int zero_ADC[20];
int DebugVar_Qnt = 1;
#pragma DATA_SECTION(dbg_vars,".dbgvar_info")
DebugVar_t dbg_vars[] = {\
{(char *)&Bender.KOhms , pt_uint16 , iq_none , "Bender.KOhms" }, \
{(char *)&ADC0startAddr , pt_int64 , iq12 , ADCdr }, \
};

BIN
dist/DebugVarEdit.exe vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_bz2.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_ctypes.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_decimal.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_elementtree.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_hashlib.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_lzma.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_socket.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_ssl.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/_wmi.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/libcrypto-3.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/libffi-8.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/libssl-3.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/msvcp140.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/msvcp140_1.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/msvcp140_2.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/pyexpat.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/pyside6.abi3.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/python3.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/python312.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/qt6core.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/qt6gui.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/qt6network.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/qt6pdf.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/qt6svg.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/qt6widgets.dll vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/select.pyd vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dist/setupVars_GUI.dist/unicodedata.pyd vendored Normal file

Binary file not shown.

BIN
dist/setupVars_GUI.dist/vcruntime140.dll vendored Normal file

Binary file not shown.

Binary file not shown.

5041
nuitka-crash-report.xml Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More