+27
-6
@@ -1,11 +1,13 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
"""Faster onefile freeze: same portable exe (fonts + plantuml.jar + onefile).
|
||||
"""Faster onefile freeze: fonts + plantuml.jar + optional Graphviz + onefile.
|
||||
|
||||
Keeps matplotlib (system font lookup) and bundles plantuml.jar.
|
||||
Graphviz (vendor/) is included when present — for offline DFD.
|
||||
Speeds Analysis by pinning the Agg backend, skipping duplicate pygments
|
||||
collection (the stock hook already pulls all lexers), and not probing Qt/Gtk.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from PyInstaller.utils.hooks import (
|
||||
@@ -18,9 +20,14 @@ from PyInstaller.utils.hooks import (
|
||||
os.environ["MPLBACKEND"] = "Agg"
|
||||
|
||||
ROOT = Path(SPECPATH).resolve()
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
from pyi_bundle import collect_tkinterdnd2, prepare_tcltk_env, sanitize_analysis # noqa: E402
|
||||
|
||||
prepare_tcltk_env()
|
||||
|
||||
datas = [
|
||||
(str(ROOT / "md2gost" / "Template.docx"), "md2gost"),
|
||||
(str(ROOT / "md2gost" / "TitleTemplate.docx"), "md2gost"),
|
||||
(str(ROOT / "md2gost" / "mml2omml"), "md2gost"),
|
||||
(str(ROOT / "md2gost" / "diagrams"), "md2gost/diagrams"),
|
||||
(str(ROOT / "prompts"), "prompts"),
|
||||
@@ -33,9 +40,20 @@ if not _plantuml.is_file():
|
||||
"сначала scripts/fetch_plantuml.py (jar обязателен в portable exe)"
|
||||
)
|
||||
datas.append((str(_plantuml), "md2gost/vendor"))
|
||||
_graphviz = ROOT / "md2gost" / "vendor" / "graphviz"
|
||||
if (_graphviz / "bin" / "dot.exe").is_file() or (_graphviz / "bin" / "dot").is_file():
|
||||
from md2gost.dfd import strip_graphviz_tcl_libs
|
||||
|
||||
strip_graphviz_tcl_libs(_graphviz)
|
||||
datas.append((str(_graphviz), "md2gost/vendor/graphviz"))
|
||||
|
||||
binaries = []
|
||||
hiddenimports = collect_submodules("md2gost")
|
||||
hiddenimports += collect_submodules("word2md")
|
||||
try:
|
||||
hiddenimports += collect_submodules("data_flow_diagram")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
datas += collect_data_files("certifi")
|
||||
datas += collect_data_files("lxml")
|
||||
@@ -95,10 +113,9 @@ hiddenimports += [
|
||||
]
|
||||
# Do NOT collect_submodules("pygments.lexers") here — hook-pygments.py already
|
||||
# collects all lexers/formatters/styles once during Analysis.
|
||||
try:
|
||||
hiddenimports += collect_submodules("tkinterdnd2")
|
||||
except Exception:
|
||||
pass
|
||||
_dnd_datas, _dnd_hidden = collect_tkinterdnd2()
|
||||
datas += _dnd_datas
|
||||
hiddenimports += _dnd_hidden
|
||||
|
||||
excludes = [
|
||||
"pytest",
|
||||
@@ -150,10 +167,14 @@ a = Analysis(
|
||||
hooksconfig={
|
||||
"matplotlib": {"backends": "Agg"},
|
||||
},
|
||||
runtime_hooks=[str(ROOT / "scripts" / "pyi_rth_mplbackend.py")],
|
||||
runtime_hooks=[
|
||||
str(ROOT / "scripts" / "pyi_rth_tcltk.py"),
|
||||
str(ROOT / "scripts" / "pyi_rth_mplbackend.py"),
|
||||
],
|
||||
excludes=excludes,
|
||||
noarchive=False,
|
||||
)
|
||||
sanitize_analysis(a)
|
||||
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user