Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing shortcut template in packaging #319

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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