Skip to content

Commit

Permalink
Add paths conditionally for mac
Browse files Browse the repository at this point in the history
CURA-11483
  • Loading branch information
casperlamboo committed Feb 5, 2024
1 parent bc0d66a commit f9d0134
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions UM/Application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2022 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.

import platform
from pathlib import Path
import argparse
import os
Expand Down Expand Up @@ -177,14 +177,19 @@ def initialize(self) -> None:
Resources.ApplicationVersion = self._version

app_root = os.path.abspath(os.path.join(os.path.dirname(sys.executable)))
Resources.addSecureSearchPath(os.path.join(app_root, "share", "uranium", "resources"))
Resources.addSecureSearchPath(os.path.join(app_root, "Resources", "share", "uranium", "resources"))

if platform.system() == "Darwin":
Resources.addSecureSearchPath(os.path.join(app_root, "Resources", "share", "uranium", "resources"))
else:
Resources.addSecureSearchPath(os.path.join(app_root, "share", "uranium", "resources"))

Resources.addSecureSearchPath(os.path.join(os.path.dirname(sys.executable), "resources"))
Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "share", "uranium", "resources"))
Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "Resources", "uranium", "resources"))
Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "Resources", "share", "uranium", "resources"))
Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "Resources", self._app_name, "resources"))

if platform.system() == "Darwin":
Resources.addSecureSearchPath(
os.path.join(self._app_install_dir, "Resources", "share", "uranium", "resources"))
else:
Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "share", "uranium", "resources"))

if not hasattr(sys, "frozen"):
uranium_data_root = os.environ.get('URANIUM_DATA_ROOT', None)
Expand All @@ -198,9 +203,12 @@ def initialize(self) -> None:
Resources.addSearchPath(str(Path(__file__).parent.parent.parent.joinpath("plugins")))

# venv site-packages
Resources.addSearchPath(str(Path(sys.executable).parent.parent.joinpath("share", "uranium", "resources")))
Resources.addSearchPath(
str(Path(sys.executable).parent.parent.joinpath("Resources", "share", "uranium", "resources")))
if platform.system() == "Darwin":
Resources.addSearchPath(
str(Path(sys.executable).parent.parent.joinpath("Resources", "share", "uranium", "resources")))
else:
Resources.addSearchPath(
str(Path(sys.executable).parent.parent.joinpath("share", "uranium", "resources")))

i18nCatalog.setApplication(self)

Expand Down Expand Up @@ -507,7 +515,10 @@ def getAppFolderPrefix() -> str:
else:
executable = sys.executable
try:
return os.path.join(os.path.dirname(os.path.realpath(executable)), "..", "Resources")
if platform.system() == "Darwin":
return os.path.join(os.path.dirname(os.path.realpath(executable)), "..", "Resources")
else:
return os.path.dirname(os.path.realpath(executable))
except EnvironmentError: # Symlinks can't be dereferenced.
return os.path.dirname(executable)

Expand Down

0 comments on commit f9d0134

Please sign in to comment.