Skip to content

Commit eb32990

Browse files
committed
Work around macOS App Translocation when packaged using pyinstaller
1 parent 80e51e4 commit eb32990

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

emailproxy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import logging.handlers
2626
import os
2727
import pathlib
28+
import platform
2829
import plistlib
2930
import queue
3031
import re
@@ -150,7 +151,10 @@ class NSObject:
150151

151152
script_path = sys.executable if getattr(sys, 'frozen', False) else os.path.realpath(__file__) # for pyinstaller etc
152153
if sys.platform == 'darwin' and '.app/Contents/MacOS/' in script_path: # pyinstaller .app binary is within the bundle
153-
script_path = '/'.join(script_path.split('Contents/MacOS/')[0].split('/')[:-1])
154+
if float('.'.join(platform.mac_ver()[0].split('.')[:2])) >= 10.12: # need a known path (due to App Translocation)
155+
script_path = pathlib.Path('~/.%s/%s' % (APP_SHORT_NAME, APP_SHORT_NAME)).expanduser()
156+
else:
157+
script_path = '.'.join(script_path.split('Contents/MacOS/')[0].split('/')[:-1])
154158
script_path = os.getcwd() if __package__ is not None else os.path.dirname(script_path) # for packaged version (PyPI)
155159
CONFIG_FILE_PATH = CACHE_STORE = os.path.join(script_path, '%s.config' % APP_SHORT_NAME)
156160
CONFIG_SERVER_MATCHER = re.compile(r'^(?P<type>(IMAP|POP|SMTP))-(?P<port>\d+)$')

0 commit comments

Comments
 (0)