diff --git a/builder/pyinstaller_build_macos.py b/builder/pyinstaller_build_macos.py index 4bf9d33e..94bdbe3f 100644 --- a/builder/pyinstaller_build_macos.py +++ b/builder/pyinstaller_build_macos.py @@ -31,6 +31,11 @@ PyInstaller.__main__.run( [ + "--add-data=LICENSE:.", + "--add-data=README.md:.", + "--add-data={}:profiles/".format( + (package_folder / "profiles/shortcut_freedesktop.template/").resolve() + ), "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), "--name={}_{}_MacOS{}_Python{}-{}".format( __about__.__title_clean__, diff --git a/builder/pyinstaller_build_ubuntu.py b/builder/pyinstaller_build_ubuntu.py index 4f39a672..dcd3af2a 100644 --- a/builder/pyinstaller_build_ubuntu.py +++ b/builder/pyinstaller_build_ubuntu.py @@ -29,6 +29,11 @@ PyInstaller.__main__.run( [ + "--add-data=LICENSE:.", + "--add-data=README.md:.", + "--add-data={}:profiles/".format( + (package_folder / "profiles/shortcut_freedesktop.template/").resolve() + ), "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), "--name={}_{}_{}{}_{}_Python{}".format( __about__.__title_clean__, diff --git a/builder/pyinstaller_build_windows.py b/builder/pyinstaller_build_windows.py index 45b89eb4..7255b0b2 100644 --- a/builder/pyinstaller_build_windows.py +++ b/builder/pyinstaller_build_windows.py @@ -28,8 +28,11 @@ PyInstaller.__main__.run( [ - "--add-data=LICENSE;.", - "--add-data=README.md;.", + "--add-data=LICENSE:.", + "--add-data=README.md:.", + "--add-data={}:profiles/".format( + (package_folder / "profiles/shortcut_freedesktop.template/").resolve() + ), # "--clean", f"--icon={package_folder.parent.resolve()}/docs/static/logo_qdt.ico", "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), diff --git a/qgis_deployment_toolbelt/profiles/shortcuts.py b/qgis_deployment_toolbelt/profiles/shortcuts.py index 1f570a58..4d71e028 100644 --- a/qgis_deployment_toolbelt/profiles/shortcuts.py +++ b/qgis_deployment_toolbelt/profiles/shortcuts.py @@ -15,6 +15,7 @@ import os import re import stat +import sys from collections.abc import Iterable from pathlib import Path from string import Template @@ -342,8 +343,19 @@ def freedesktop_create(self) -> tuple[Path | None, Path | None]: :return: desktop and startmenu path :rtype: Tuple[Union[Path, None], Union[Path, None]] """ - # prepare shortcut - template_shortcut = Path(__file__).parent / "shortcut_freedesktop.template" + # grab shortcut template depending if we are in frozen mode + # (typically PyInstaller) or as "normal" Python + if not (getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")): + template_shortcut = Path(__file__).parent / "shortcut_freedesktop.template" + logger.debug(f"Using shortcut template in Python mode: {template_shortcut}") + else: + template_shortcut = Path(getattr(sys, "_MEIPASS", sys.executable)).joinpath( + "profiles/shortcut_freedesktop.template" + ) + logger.debug( + f"Using shortcut template in packaged mode: {template_shortcut}" + ) + check_path( input_path=template_shortcut, must_be_a_file=True,