From ada99077a4b87a5b7cebc2c4f0c97b06d3d2b2a1 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 8 Feb 2021 09:44:10 +0100 Subject: [PATCH] Fix some issues with resolving paths for a packaged single executable --- nw/config.py | 7 +++++-- nw/gui/theme.py | 2 +- setup.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/nw/config.py b/nw/config.py index d35582fb..4084394f 100644 --- a/nw/config.py +++ b/nw/config.py @@ -272,8 +272,11 @@ class Config: self.appPath = getattr(sys, "_MEIPASS", os.path.abspath(os.path.dirname(__file__))) self.appRoot = os.path.abspath(os.path.join(self.appPath, os.path.pardir)) - if self.appRoot.endswith(".pyz"): - self.appRoot = os.path.abspath(os.path.join(self.appRoot, os.path.pardir)) + if os.path.isfile(self.appRoot): + # novelWriter is packaged as a single file, so the app and + # root paths are the same, and equal to the folder that + # contains the single executable. + self.appRoot = os.path.dirname(self.appRoot) self.appPath = self.appRoot # Assets diff --git a/nw/gui/theme.py b/nw/gui/theme.py index 1b3c1263..84628cf0 100644 --- a/nw/gui/theme.py +++ b/nw/gui/theme.py @@ -203,7 +203,7 @@ class GuiTheme: return def updateFont(self): - """Updated the GUI's font style from settings, + """Update the GUI's font style from settings. """ theFont = QFont() if self.mainConf.guiFont not in self.guiFontDB.families(): diff --git a/setup.py b/setup.py index 99d985e1..c9c9d302 100755 --- a/setup.py +++ b/setup.py @@ -402,7 +402,7 @@ def makeSimplePackage(embedPython): print("Writing: __main__.py") with open(os.path.join(zipDir, "__main__.py"), mode="w") as outFile: outFile.write( - "#!\"pythonw.exe\"\n" + "#!/usr/bin/env python3\n" "\n" "import os\n" "import sys\n" @@ -419,7 +419,7 @@ def makeSimplePackage(embedPython): print("") pyzFile = os.path.join(outDir, "novelWriter.pyz") - zipapp.create_archive(zipDir, target=pyzFile, interpreter="python3") + zipapp.create_archive(zipDir, target=pyzFile, interpreter="/usr/bin/env python3") # Install Dependencies # ====================