diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/extensions/print_pdf.py | 10 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/gui/electron.py | 19 | ||||
| -rw-r--r-- | lib/i18n.py | 5 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/inx/utils.py | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/utils/paths.py | 10 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/utils/version.py | 5 |
6 files changed, 42 insertions, 11 deletions
diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index e5cb25d8..97a806a7 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -73,7 +73,10 @@ class PrintPreviewServer(Thread): def __set_resources_path(self): if getattr(sys, 'frozen', False): - self.resources_path = os.path.join(sys._MEIPASS, 'print', 'resources') + if sys.platform == "darwin": + self.resources_path = os.path.join(sys._MEIPASS, "..", 'Resources', 'print', 'resources') + else: + self.resources_path = os.path.join(sys._MEIPASS, 'print', 'resources') else: self.resources_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', 'print', 'resources')) @@ -183,7 +186,10 @@ class PrintPreviewServer(Thread): class Print(InkstitchExtension): def build_environment(self): if getattr(sys, 'frozen', False): - print_dir = os.path.join(sys._MEIPASS, "print") + if sys.platform == "darwin": + print_dir = os.path.join(sys._MEIPASS, "..", 'Resources', "print") + else: + print_dir = os.path.join(sys._MEIPASS, "print") else: print_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "print")) diff --git a/lib/gui/electron.py b/lib/gui/electron.py index dcf03c6f..651080a9 100644..100755 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -22,7 +22,7 @@ def open_url(url): electron_path = os.path.join(get_bundled_dir("electron"), "inkstitch-gui") if sys.platform == "darwin": - electron_path += ".app/Contents/MacOS/inkstitch-gui" + electron_path = os.path.join(sys._MEIPASS, "electron", "inkstitch-gui.app", "Contents", "MacOS", "inkstitch-gui") command = ["open", "-W", "-a", electron_path, "--args", url] else: command = [electron_path, url] @@ -32,5 +32,18 @@ def open_url(url): cwd = get_bundled_dir("electron") # Any output on stdout will crash inkscape. - with open(os.devnull, 'w') as null: - return subprocess.Popen(command, cwd=cwd, stdout=null) + # In macos manual install the python env paths are incomplete + # Adding the yarn path to the env paths fixes this issue + if sys.platform == "darwin" and getattr(sys, 'frozen', None) is None: + mac_dev_env = os.environ.copy() + # these are paths installed by brew or macports + yarn_path = "/usr/local/bin:/opt/local/bin:" + if yarn_path in mac_dev_env["PATH"]: + pass + else: + mac_dev_env["PATH"] = yarn_path + mac_dev_env["PATH"] + with open(os.devnull, 'w') as null: + return subprocess.Popen(command, cwd=cwd, stdout=null, env=mac_dev_env) + else: + with open(os.devnull, 'w') as null: + return subprocess.Popen(command, cwd=cwd, stdout=null) diff --git a/lib/i18n.py b/lib/i18n.py index 37972e36..204381dc 100644 --- a/lib/i18n.py +++ b/lib/i18n.py @@ -30,7 +30,10 @@ def _set_locale_dir(): else: locale_dir = dirname(dirname(realpath(__file__))) - locale_dir = os.path.join(locale_dir, 'locales') + if sys.platform == "darwin": + locale_dir = os.path.join(locale_dir, "..", 'Resources', 'locales') + else: + locale_dir = os.path.join(locale_dir, 'locales') def localize(languages=None): diff --git a/lib/inx/utils.py b/lib/inx/utils.py index acee88ad..31da518e 100644..100755 --- a/lib/inx/utils.py +++ b/lib/inx/utils.py @@ -35,8 +35,8 @@ def build_environment(): env.globals["command_tag"] = '<command location="inx">../bin/inkstitch.exe</command>' env.globals["image_path"] = '../bin/icons/' elif sys.platform == "darwin": - env.globals["command_tag"] = '<command location="inx">../MacOS/inkstitch</command>' - env.globals["image_path"] = '../MacOS/icons/' + env.globals["command_tag"] = '<command location="inx">../../MacOS/inkstitch</command>' + env.globals["image_path"] = '../../Resources/icons/' else: env.globals["command_tag"] = '<command location="inx">../bin/inkstitch</command>' env.globals["image_path"] = '../bin/icons/' diff --git a/lib/utils/paths.py b/lib/utils/paths.py index 938c5f33..2a95f6e7 100644..100755 --- a/lib/utils/paths.py +++ b/lib/utils/paths.py @@ -10,13 +10,19 @@ from os.path import dirname, realpath def get_bundled_dir(name): if getattr(sys, 'frozen', None) is not None: - return realpath(os.path.join(sys._MEIPASS, "..", name)) + if sys.platform == "darwin": + return realpath(os.path.join(sys._MEIPASS, "..", 'Resources', name)) + else: + return realpath(os.path.join(sys._MEIPASS, "..", name)) else: return realpath(os.path.join(dirname(realpath(__file__)), '..', '..', name)) def get_resource_dir(name): if getattr(sys, 'frozen', None) is not None: - return realpath(os.path.join(sys._MEIPASS, name)) + if sys.platform == "darwin": + return realpath(os.path.join(sys._MEIPASS, "..", 'Resources', name)) + else: + return realpath(os.path.join(sys._MEIPASS, name)) else: return realpath(os.path.join(dirname(realpath(__file__)), '..', '..', name)) diff --git a/lib/utils/version.py b/lib/utils/version.py index 2186ca23..0b46669a 100644..100755 --- a/lib/utils/version.py +++ b/lib/utils/version.py @@ -11,7 +11,10 @@ from ..i18n import _ def get_inkstitch_version(): if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): - version = realpath(join(sys._MEIPASS, "..", "VERSION")) + if sys.platform == "darwin": + version = realpath(join(sys._MEIPASS, "..", 'Resources', "VERSION")) + else: + version = realpath(join(sys._MEIPASS, "..", "VERSION")) else: version = realpath(join(realpath(__file__), "..", "..", "..", 'VERSION')) if isfile(version): |
