From 1b3be6e668d1ec01e7a3a0703098d68b18d71468 Mon Sep 17 00:00:00 2001 From: Julien M Date: Wed, 8 Nov 2023 11:46:35 +0100 Subject: [PATCH 1/3] Fix missing shortcut template in packaging --- builder/pyinstaller_build_macos.py | 5 +++++ builder/pyinstaller_build_ubuntu.py | 7 ++++++- builder/pyinstaller_build_windows.py | 9 ++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) 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..76ea4279 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__, @@ -40,7 +45,7 @@ ).replace(".", "-"), "--noconfirm", "--noupx", - "--onefile", + # "--onefile", "--console", str(package_folder / "cli.py"), ] diff --git a/builder/pyinstaller_build_windows.py b/builder/pyinstaller_build_windows.py index 45b89eb4..1a89bd5d 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")), @@ -44,7 +47,7 @@ ), "--noconfirm", "--noupx", - "--onefile", + # "--onefile", "--version-file={}".format("version_info.txt"), "--console", str(package_folder / "cli.py"), From 4e8c21527612337287eb7687270b60db271893ed Mon Sep 17 00:00:00 2001 From: Julien M Date: Wed, 8 Nov 2023 11:52:07 +0100 Subject: [PATCH 2/3] Restore onefile option --- builder/pyinstaller_build_ubuntu.py | 2 +- builder/pyinstaller_build_windows.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/pyinstaller_build_ubuntu.py b/builder/pyinstaller_build_ubuntu.py index 76ea4279..dcd3af2a 100644 --- a/builder/pyinstaller_build_ubuntu.py +++ b/builder/pyinstaller_build_ubuntu.py @@ -45,7 +45,7 @@ ).replace(".", "-"), "--noconfirm", "--noupx", - # "--onefile", + "--onefile", "--console", str(package_folder / "cli.py"), ] diff --git a/builder/pyinstaller_build_windows.py b/builder/pyinstaller_build_windows.py index 1a89bd5d..7255b0b2 100644 --- a/builder/pyinstaller_build_windows.py +++ b/builder/pyinstaller_build_windows.py @@ -47,7 +47,7 @@ ), "--noconfirm", "--noupx", - # "--onefile", + "--onefile", "--version-file={}".format("version_info.txt"), "--console", str(package_folder / "cli.py"), From ceeaf5388328d23d4119afe9852c594edd236b24 Mon Sep 17 00:00:00 2001 From: Julien M Date: Wed, 8 Nov 2023 12:25:38 +0100 Subject: [PATCH 3/3] Fix path to shortcut template in PyInstaller pkg --- qgis_deployment_toolbelt/profiles/shortcuts.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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,