Skip to content

Commit

Permalink
Add portable install option
Browse files Browse the repository at this point in the history
  • Loading branch information
QCanvas committed Jul 30, 2024
1 parent 21dfdc8 commit 6821b3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "qcanvas"
version = "1.0.12.dev1"
version = "1.0.12.dev2"
description = "QCanvas is a desktop client for Canvas LMS."
authors = ["QCanvas <[email protected]>"]
readme = "README.md"
Expand Down
14 changes: 9 additions & 5 deletions qcanvas/util/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@

_logger = logging.getLogger(__name__)

_is_running_portable = Path(".portable").exists()
_is_running_on_windows = platform.system() == "Windows"
_is_running_on_linux = platform.system() == "Linux"
_is_running_as_pyinstaller = getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")
_is_running_as_flatpak = os.environ.get("container", "") == "flatpak"


def client_settings() -> QSettings:
if _is_running_as_pyinstaller and _is_running_on_windows:
if _is_running_portable:
return QSettings("QCanvas.ini", QSettings.Format.IniFormat)
elif _is_running_as_pyinstaller and _is_running_on_windows:
return QSettings(
str(platformdirs.user_documents_path() / "QCanvasTeam" / "QCanvas.ini"),
QSettings.Format.IniFormat,
Expand All @@ -30,10 +33,11 @@ def client_settings() -> QSettings:
def root() -> Path:
root_path = Path()

if _is_running_as_flatpak:
root_path = Path(os.environ["XDG_DATA_HOME"])
elif _is_running_as_pyinstaller:
root_path = platformdirs.user_data_path("QCanvasReborn", "QCanvasTeam")
if not _is_running_portable:
if _is_running_as_flatpak:
root_path = Path(os.environ["XDG_DATA_HOME"])
elif _is_running_as_pyinstaller:
root_path = platformdirs.user_data_path("QCanvasReborn", "QCanvasTeam")

print("Root path", root_path.absolute())
_logger.debug("Root path %s", root_path.absolute())
Expand Down

0 comments on commit 6821b3e

Please sign in to comment.