Skip to content

Commit

Permalink
Fix missing shortcut template in packaging (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts authored Nov 8, 2023
2 parents 61b92d1 + ceeaf53 commit 16c8150
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
5 changes: 5 additions & 0 deletions builder/pyinstaller_build_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__,
Expand Down
5 changes: 5 additions & 0 deletions builder/pyinstaller_build_ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__,
Expand Down
7 changes: 5 additions & 2 deletions builder/pyinstaller_build_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down
16 changes: 14 additions & 2 deletions qgis_deployment_toolbelt/profiles/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 16c8150

Please sign in to comment.