Fix PyInstaller packaging for CephDeploy

parent 766f2065
...@@ -15,6 +15,9 @@ env/ ...@@ -15,6 +15,9 @@ env/
# PyInstaller # PyInstaller
build/ build/
dist/ dist/
.pyinstaller-cache/
.matplotlib-cache/
share/
*.spec.bak *.spec.bak
# Локальная БД CephDeploy — содержит пользовательские кластеры, # Локальная БД CephDeploy — содержит пользовательские кластеры,
......
...@@ -43,9 +43,14 @@ a = Analysis( ...@@ -43,9 +43,14 @@ a = Analysis(
], ],
hookspath=[], hookspath=[],
hooksconfig={}, hooksconfig={},
runtime_hooks=[], runtime_hooks=[str(ROOT / 'hooks' / 'rthook_matplotlib_data.py')],
excludes=[ excludes=[
'tkinter', 'unittest', 'xmlrpc', 'pydoc', 'tkinter', 'xmlrpc', 'pydoc',
# CephDeploy uses PyQt6. The build environment also contains PySide6,
# and PyInstaller aborts if multiple Qt bindings are collected.
'PySide6', 'shiboken6',
'PySide2', 'shiboken2',
'PyQt5',
], ],
noarchive=False, noarchive=False,
optimize=2, optimize=2,
......
"""Prepare Matplotlib data path for PyInstaller builds on ALT Linux."""
from __future__ import annotations
import os
import shutil
import sys
from pathlib import Path
def _prepare_matplotlib_data() -> None:
bundle_dir = getattr(sys, "_MEIPASS", None)
if not bundle_dir:
return
bundle_dir = Path(bundle_dir)
actual = bundle_dir / "matplotlib" / "mpl-data"
if not actual.exists():
return
# ALT's Matplotlib 3.10 calculates mpl-data from matplotlib.__file__ as:
# Path(__file__).parent.parent.parent.parent.parent / "share/matplotlib/mpl-data".
expected = (
(bundle_dir / "matplotlib" / "__init__.py")
.parent.parent.parent.parent.parent
/ "share"
/ "matplotlib"
/ "mpl-data"
)
if expected.exists():
return
try:
expected.parent.mkdir(parents=True, exist_ok=True)
os.symlink(actual, expected)
except OSError:
if not expected.exists():
shutil.copytree(actual, expected, dirs_exist_ok=True)
_prepare_matplotlib_data()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment